Skip to main content

http_output_deserializer

Function http_output_deserializer 

Source
pub fn http_output_deserializer<'a, D>(
    body: D,
    response: &'a Response,
    output_schema: &Schema<'_>,
    cfg: &'a ConfigBag,
) -> Box<dyn ShapeDeserializer + 'a>
where D: ShapeDeserializer + 'a,
Expand description

Wraps a protocol’s body deserializer so a successful response’s transport-bound members are read from the HTTP message.

Every REST construction site must go through this or http_error_deserializer, for two reasons. It is the single place binding behavior is decided, so a protocol wrapper cannot accidentally return a bare body deserializer and silently drop header members. And it is generic over the concrete body deserializer, so the composite is built before the result is coerced to Box<dyn ShapeDeserializer> — exactly one allocation per response, matching what the body-only path already costs. Boxing the body first and wrapping the box would add a second.

§The body-only fast path

When the output structure has no response-bound members but does have body members, the composite has nothing to contribute and the body deserializer is returned directly. This keeps body-only REST outputs off the composite entirely.

Both halves of the condition matter. An empty output has no body members either, and for it the composite is the better answer: it skips the codec instead of asking the codec to accept an empty body. A non-structure schema — such as prelude::DOCUMENT — carries a zeroed routing word, so it reports no body members and also routes through the composite rather than being mistaken for a body-only output.