pub struct Server { /* private fields */ }
Expand description
The Server
Implementations§
source§impl Server
impl Server
sourcepub fn run() -> Self
pub fn run() -> Self
Start a server, panicking if unable to start.
The server will run in the background. On Drop it will terminate and assert it’s expectations.
sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Get the address the server is listening on.
sourcepub fn url(&self, path_and_query: &str) -> Uri
pub fn url(&self, path_and_query: &str) -> Uri
Get a fully formed url to the servers address.
If the server is listening on port 1234.
server.url("/foo?q=1") == "http://localhost:1234/foo?q=1"
sourcepub fn url_str(&self, path_and_query: &str) -> String
pub fn url_str(&self, path_and_query: &str) -> String
Get a fully formed url to the servers address as a String.
server.url_str(foo) == server.url(foo).to_string()
sourcepub fn expect(&self, expectation: Expectation)
pub fn expect(&self, expectation: Expectation)
Add a new expectation to the server.
sourcepub fn verify_and_clear(&mut self)
pub fn verify_and_clear(&mut self)
Verify all registered expectations. Panic if any are not met, then clear all expectations leaving the server running in a clean state.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
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