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: VersionThe HTTP version
headers: HeaderMapThe set of headers
Should always at least have Content-Type. Servers will override Content-Length on serialization.
status: StatusCodeThe status code
output: MThe 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.
Auto Trait Implementations§
impl<M> Freeze for ServiceResponse<M>where
M: Freeze,
impl<M> RefUnwindSafe for ServiceResponse<M>where
M: RefUnwindSafe,
impl<M> Send for ServiceResponse<M>
impl<M> Sync for ServiceResponse<M>
impl<M> Unpin for ServiceResponse<M>where
M: Unpin,
impl<M> UnsafeUnpin for ServiceResponse<M>where
M: UnsafeUnpin,
impl<M> UnwindSafe for ServiceResponse<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more