pub struct MessageResource {
pub key: Option<String>,
pub message: String,
}
Expand description
This is for sending errors back from requests conveniently. This struct contains an optional key just in case you want to deal with internationalization. It was left as optional just in case you don’t have the time to yet…
Fields§
§key: Option<String>
§message: String
Implementations§
Source§impl MessageResource
impl MessageResource
pub fn new_empty() -> MessageResource
pub fn new_from_str(msg: &str) -> MessageResource
Sourcepub fn new_from_err<E: Display>(error: E) -> MessageResource
pub fn new_from_err<E: Display>(error: E) -> MessageResource
Just takes any error that implements display (Has a .to_string() method)
pub fn new(key: &str, msg: &str) -> MessageResource
Trait Implementations§
Source§impl Clone for MessageResource
impl Clone for MessageResource
Source§fn clone(&self) -> MessageResource
fn clone(&self) -> MessageResource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for MessageResource
impl Debug for MessageResource
Source§impl<'de> Deserialize<'de> for MessageResource
impl<'de> Deserialize<'de> for MessageResource
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 Display for MessageResource
impl Display for MessageResource
Source§impl ReturnableErrorShape for MessageResource
impl ReturnableErrorShape for MessageResource
fn convert_to_returnable<T: Serialize>( &self, status_code: u16, ) -> TypedHttpResponse<T>
Auto Trait Implementations§
impl Freeze for MessageResource
impl RefUnwindSafe for MessageResource
impl Send for MessageResource
impl Sync for MessageResource
impl Unpin for MessageResource
impl UnwindSafe for MessageResource
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