Skip to main content

bridge_grpc_response

Function bridge_grpc_response 

Source
pub async fn bridge_grpc_response<C, T>(
    response: Response<Body>,
    codec: &C,
    headers: &HeaderMap,
) -> Result<T, (String, String)>
Expand description

headers must be the same HeaderMap passed to the dispatch call that produced response — no Content-Type/Accept set, so content negotiation resolves to the same default codec on both the dispatch side and this decode side (mirrors decode_rpc_body’s own DEFAULT_CONTENT_TYPE fallback, reused unchanged here).

Ok(value) on a 2xx dispatch response, decoded straight to T. Err((code, message)) otherwise — either the dispatch response’s own CoolErrorResponse (its code is cratestack_core::CoolError::code()’s screaming-snake vocabulary, e.g. "NOT_FOUND"), or, if buffering / decoding the response body itself fails, a synthesized "INTERNAL_ERROR". Callers map code to a tonic::Status via cratestack_grpc::cool_error_code_to_tonic_code.