pub struct StaticResponses { /* private fields */ }Expand description
Pre-serialized static responses — the memcpy fast path.
A table from request path to the FULLY rendered wire bytes of a response, in both connection dispositions. A serve entry carrying a table answers a matching request by copying bytes straight into the socket, before (and instead of) dispatching the handler.
Both variants are rendered by the same serialize_response_conn the
handler path uses, so table bytes are byte-identical to what the handler
path would produce for the same HttpResponse — the invariant the
engine differential asserts.
Matching is deliberately conservative: only GET requests with an empty
query string hit the table (anything else — POST, a ?query, an unknown
path — falls through to the handler).
Implementations§
Source§impl StaticResponses
impl StaticResponses
pub fn new() -> Self
Sourcepub fn insert(&mut self, path: &str, resp: &HttpResponse)
pub fn insert(&mut self, path: &str, resp: &HttpResponse)
Render resp into both wire variants and file them under path.
Sourcepub fn wire_frame(&self, req: &HttpRequest, keep_alive: bool) -> Option<&[u8]>
pub fn wire_frame(&self, req: &HttpRequest, keep_alive: bool) -> Option<&[u8]>
The pre-rendered wire frame for req under the given disposition, if
the table answers it.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Trait Implementations§
Source§impl Clone for StaticResponses
impl Clone for StaticResponses
Source§fn clone(&self) -> StaticResponses
fn clone(&self) -> StaticResponses
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more