pub struct Server {
pub(crate) address: SocketAddr,
pub(crate) requests: Arc<Mutex<Vec<Request>>>,
pub(crate) accept_loop: JoinHandle<()>,
}Expand description
A server listening on 127.0.0.1 with a port the kernel picked.
Dropping it stops the accept loop.
Fields§
§address: SocketAddr§requests: Arc<Mutex<Vec<Request>>>§accept_loop: JoinHandle<()>Implementations§
Source§impl Server
impl Server
Sourcepub fn start(responses: Vec<Response>) -> Self
pub fn start(responses: Vec<Response>) -> Self
Start a server that answers responses in order.
Once the list runs out the last entry is repeated, so a retrying client keeps meeting the same answer.
Sourcepub fn start_with<F: FnOnce(SocketAddr) -> Vec<Response> + Send + 'static>(
build_responses: F,
) -> Self
pub fn start_with<F: FnOnce(SocketAddr) -> Vec<Response> + Send + 'static>( build_responses: F, ) -> Self
Start a server whose responses are built once the bound address is known, for a response body that embeds the server’s own URL.
§Panics
Panics when the background server cannot report its address, which only happens if its accept loop could not even bind a port.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Server
impl RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl UnsafeUnpin 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