pub struct Server<const P: usize = DEFAULT_HANDLER_TASKS_COUNT, const B: usize = DEFAULT_BUF_SIZE, const N: usize = DEFAULT_MAX_HEADERS_COUNT>(/* private fields */);Expand description
An HTTP server that can handle multiple requests concurrently.
The server needs an implementation of edge_nal::TcpAccept to accept incoming connections.
Implementations§
Source§impl<const P: usize, const B: usize, const N: usize> Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> Server<P, B, N>
Sourcepub async fn run<A, H>(
&mut self,
keepalive_timeout_ms: Option<u32>,
acceptor: A,
handler: H,
) -> Result<(), Error<A::Error>>
pub async fn run<A, H>( &mut self, keepalive_timeout_ms: Option<u32>, acceptor: A, handler: H, ) -> Result<(), Error<A::Error>>
Run the server with the specified acceptor and handler
A note on timeouts:
- The function does NOT - by default - establish any timeouts on the IO operations except
an optional timeout on idle connections, so that they can be closed.
It is up to the caller to wrap the acceptor type with
edge_nal::WithTimeoutto establish timeouts on the socket produced by the acceptor. - Similarly, the function does NOT establish any timeouts on the complete request-response cycle.
It is up to the caller to wrap their complete or partial handling logic with
edge_nal::with_timeout, or its whole handler withedge_nal::WithTimeout, so as to establish a global or semi-global request-response timeout.
Parameters:
keepalive_timeout_ms: An optional timeout in milliseconds for detecting an idle keepalive connection that should be closed. If not provided, the function will not close idle connections and the connection - in the absence of other timeouts - will remain active forever.acceptor: An implementation ofedge_nal::TcpAcceptto accept incoming connectionshandler: An implementation ofHandlerto handle incoming requests If not provided, a default timeout of 50 seconds is used.
Trait Implementations§
Auto Trait Implementations§
impl<const P: usize, const B: usize, const N: usize> Freeze for Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> RefUnwindSafe for Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> Send for Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> Sync for Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> Unpin for Server<P, B, N>
impl<const P: usize, const B: usize, const N: usize> UnwindSafe for Server<P, B, N>
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