pub struct ResponseEnvelope {
pub body: Result<Vec<u8>, ResponseError>,
}Expand description
This is the struct that we serialize and send back to the client
// Success case
let response = ResponseEnvelope::new(vec![1, 2, 3]);
assert!(response.body.is_ok());
// Error case
let response_error = ResponseError::Unknown("something went wrong".to_string());
let response = ResponseEnvelope::err(response_error);
assert!(response.body.is_err());Fields§
§body: Result<Vec<u8>, ResponseError>Implementations§
Source§impl ResponseEnvelope
impl ResponseEnvelope
Sourcepub fn new(body: Vec<u8>) -> ResponseEnvelope
pub fn new(body: Vec<u8>) -> ResponseEnvelope
New ResponseEnvelope. Ok Variant
Sourcepub fn err(error: ResponseError) -> ResponseEnvelope
pub fn err(error: ResponseError) -> ResponseEnvelope
New ResponseEnvelope. Err Variant
Trait Implementations§
Source§impl Debug for ResponseEnvelope
impl Debug for ResponseEnvelope
Source§impl<'de> Deserialize<'de> for ResponseEnvelope
impl<'de> Deserialize<'de> for ResponseEnvelope
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<HandlerError> for ResponseEnvelope
Convert a HandlerError into a ResponseEnvelope.
impl From<HandlerError> for ResponseEnvelope
Convert a HandlerError into a ResponseEnvelope.
This is used to convert errors that occur during handler execution into a response envelope that can be sent back to the client.
Source§fn from(error: HandlerError) -> Self
fn from(error: HandlerError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ResponseEnvelope
impl RefUnwindSafe for ResponseEnvelope
impl Send for ResponseEnvelope
impl Sync for ResponseEnvelope
impl Unpin for ResponseEnvelope
impl UnsafeUnpin for ResponseEnvelope
impl UnwindSafe for ResponseEnvelope
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more