Struct prost_twirp::ServiceResponse
source · pub struct ServiceResponse<M: Message> {
pub version: Version,
pub headers: HeaderMap,
pub status: StatusCode,
pub output: M,
}
Expand description
A response with HTTP info and the output object as a protobuf Message.
Fields§
§version: Version
The HTTP version
headers: HeaderMap
The set of headers
Should always at least have Content-Type
. Servers will override Content-Length
on serialization.
status: StatusCode
The status code
output: M
The output object
Implementations§
source§impl<M: Message> ServiceResponse<M>
impl<M: Message> ServiceResponse<M>
sourcepub fn new(output: M) -> ServiceResponse<M>
pub fn new(output: M) -> ServiceResponse<M>
Create new service request with the given input object
This automatically sets the Content-Type
header as application/protobuf
.
sourcepub fn clone_with_output(&self, output: M) -> ServiceResponse<M>
pub fn clone_with_output(&self, output: M) -> ServiceResponse<M>
Copy this response with a different output value
source§impl<M: Message + Default> ServiceResponse<M>
impl<M: Message + Default> ServiceResponse<M>
sourcepub async fn from_hyper_response(
resp: Response<Body>
) -> Result<Self, ProstTwirpError>
pub async fn from_hyper_response(
resp: Response<Body>
) -> Result<Self, ProstTwirpError>
Deserialze an object response from a hyper response.
sourcepub fn to_hyper_response(&self) -> Result<Response<Body>, ProstTwirpError>
pub fn to_hyper_response(&self) -> Result<Response<Body>, ProstTwirpError>
Serialize an object response into a hyper response.
Trait Implementations§
source§impl<M: Message + Default + 'static> From<M> for ServiceResponse<M>
impl<M: Message + Default + 'static> From<M> for ServiceResponse<M>
source§fn from(v: M) -> ServiceResponse<M>
fn from(v: M) -> ServiceResponse<M>
Converts to this type from the input type.