Serve
pub struct Serve { /* private fields */ }Support for processing multiple requests from a single sandbox.
Methods
new
View sourcefn new() -> SelfPrepare a new Serve instance for handling requests in this sandbox.
Returns
run
View sourcewhere F: FnMut(Request) -> MaybeResult, MaybeResult: HandlerResult,Begin serving requests in this sandbox.
Parameters
- self: Self
- handler: F
Returns
run_with_context
View sourcefn run_with_context<F, C, MaybeResult>(self, handler: F, cx: &mut C) -> ServeSummary<MaybeResult::Error>where F: FnMut(Request, &mut C) -> MaybeResult, MaybeResult: HandlerResult,Begin serving requests in this sandbox, but with a contextual argument passed to every invocation of the handler callback.
The callback should return a type that implements HandlerResult, such as:
Response, if it always returns a response.Result<Response, E>, if it might fail with an error of typeEinstead of generating a response
Parameters
- self: Self
- handler: F
- cx: &mut C
Returns
with_max_lifetime
View sourceConfigure when to stop accepting additional requests.
Defaults to Duration::MAX.
Parameters
- self: Self
- limit: Duration
Returns
with_max_memory
View sourcefn with_max_memory(self, mib: u32) -> SelfConfigure the maximum amount of memory (in mebibytes) to allow this instance to use before stopping, as reported by heapmemorysnapshot_mib.
A limit of 0 (the default) will be treated as unlimited.
Parameters
- self: Self
- mib: u32
Returns
with_max_requests
View sourcefn with_max_requests(self, limit: usize) -> SelfConfigure the maximum number of requests to serve before stopping.
A limit of 0 (the default) will be treated as unlimited.
Parameters
- self: Self
- limit: usize
Returns
with_timeout
View sourceConfigure how long to wait for another request before stopping.
Defaults to Duration::MAX.
Parameters
- self: Self
- timeout: Duration
Returns