Skip to main content

response_to_frame

Function response_to_frame 

Source
pub async fn response_to_frame<C>(
    id: u64,
    response: Response<Body>,
    codec: &C,
    headers: &HeaderMap,
) -> RpcResponseFrame
where C: HttpTransport,
Expand description

Convert an [axum::Response] returned by an inner dispatch arm into a single batch response frame.

Success bodies (2xx) are decoded as serde_json::Value via the same codec the request used and become RpcResponseFrame::ok. Error bodies (4xx/5xx) — which have already been post-processed by super::convert_handler_error_response inside rpc_dispatch_inner — are decoded as RpcErrorBody and inlined into RpcResponseFrame::error directly.

Wire limitation: success outputs must be representable as serde_json::Value. For CRUD/procedure outputs this is fine; if a future op returns CBOR-only types (e.g. raw byte strings without a JSON representation) the frame becomes an internal error.