pub struct Response {
pub status_code: u32,
pub status: String,
pub header: HashMap<String, String>,
pub body: Vec<u8>,
}Expand description
Represents an HTTP response that the guest module would like to return in response to a request command
Fields§
§status_code: u32HTTP status code of the response
status: StringStatus text
header: HashMap<String, String>Headers
body: Vec<u8>Body of the response
Implementations§
Source§impl Response
impl Response
Sourcepub fn json<T>(payload: T, status_code: u32, status: &str) -> Responsewhere
T: Serialize,
pub fn json<T>(payload: T, status_code: u32, status: &str) -> Responsewhere
T: Serialize,
Creates a response with a given status code and serializes the given payload as JSON
Sourcepub fn internal_server_error(msg: &str) -> Response
pub fn internal_server_error(msg: &str) -> Response
Useful shortcut for creating a 500/Internal Server Error response
Sourcepub fn bad_request() -> Response
pub fn bad_request() -> Response
Shortcut for creating a 400/Bad Request response
Trait Implementations§
Source§impl Message for Response
impl Message for Response
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Returns the encoded length of the message without a length delimiter.
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Encodes the message to a buffer. Read more
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Encodes the message with a length-delimiter to a buffer. Read more
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Decodes an instance of the message from a buffer. Read more
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Decodes a length-delimited instance of the message from the buffer.
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
Decodes an instance of the message from a buffer, and merges it into
self. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
Decodes a length-delimited instance of the message from buffer, and
merges it into
self.impl StructuralPartialEq for Response
Auto Trait Implementations§
impl Freeze for Response
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnsafeUnpin for Response
impl UnwindSafe for Response
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