/// Write the provided prost::Message as a serialized protobuf into a Response
/// object.
Write the provided prost::Message as a serialized protobuf into a Response
object.
Write the provided prost :: Message as a serialized protobuf into a Response object .
pub(crate) fn protobuf_response<R: Message>(r: &R) -> Response<Body> {
    use hyper::header;
    let mut buf = Vec::<u8>::new();
    r.encode(&mut buf)
        .expect("impossible: Serialization failed");
    let mut response = Response::new(Body::from(buf));
    *response.status_mut() = StatusCode::OK;
    *response.headers_mut() = get_cors_headers();
    response.headers_mut().insert(
        header::CONTENT_TYPE,
        header::HeaderValue::from_static(CONTENT_TYPE_PROTOBUF),
    );
    response
}
pub ( crate ) fn protobuf_response < R : Message > ( r : & R ) -> Response < Body > { use hyper :: header ; let mut buf = Vec :: < u8 > :: new ( ) ; r . encode ( & mut buf ) . expect ( " " ) ; let mut response = Response :: new ( Body :: from ( buf ) ) ; * response . status_mut ( ) = StatusCode :: OK ; * response . headers_mut ( ) = get_cors_headers ( ) ; response . headers_mut ( ) . insert ( header :: CONTENT_TYPE , header :: HeaderValue :: from_static ( CONTENT_TYPE_PROTOBUF ) , ) ; response }
Write the provided prost::Message as a serialized protobuf into a Response
object.
Write the provided prost :: Message as a serialized protobuf into a Response object .
r
&R