pub struct ServerGuard { /* private fields */ }
Expand description
A handle around a pooled Server
object which dereferences to Server
.
Methods from Deref<Target = Server>§
Sourcepub fn mock<P: Into<Matcher>>(&mut self, method: &str, path: P) -> Mock
pub fn mock<P: Into<Matcher>>(&mut self, method: &str, path: P) -> Mock
Initializes a mock with the given HTTP method
and path
.
The mock is enabled on the server only after calling the Mock::create
method.
§Example
let mut s = mockito::Server::new();
let _m1 = s.mock("GET", "/");
let _m2 = s.mock("POST", "/users");
let _m3 = s.mock("DELETE", "/users?id=1");
Sourcepub fn host_with_port(&self) -> String
pub fn host_with_port(&self) -> String
The host and port of the mock server.
Can be used with std::net::TcpStream
.
Sourcepub fn socket_address(&self) -> SocketAddr
pub fn socket_address(&self) -> SocketAddr
The raw address of the mock server.
Sourcepub async fn reset_async(&mut self)
👎Deprecated since 1.0.1: Use Server::reset
instead
pub async fn reset_async(&mut self)
Server::reset
insteadDEPRECATED: Use Server::reset
instead. The implementation is not async any more.
Trait Implementations§
Source§impl Deref for ServerGuard
impl Deref for ServerGuard
Source§impl DerefMut for ServerGuard
impl DerefMut for ServerGuard
Auto Trait Implementations§
impl Freeze for ServerGuard
impl !RefUnwindSafe for ServerGuard
impl Send for ServerGuard
impl Sync for ServerGuard
impl Unpin for ServerGuard
impl !UnwindSafe for ServerGuard
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more