pub struct Envelope {
pub id: Uuid,
pub from: String,
pub to: String,
pub payload: Value,
}Expand description
Point-to-point mailbox message stored as JSON in mailbox/<to>/<id>.txt.
Fields§
§id: Uuid§from: String§to: String§payload: ValueImplementations§
Source§impl Envelope
impl Envelope
pub fn new( from: impl Into<String>, to: impl Into<String>, payload: Value, ) -> Self
pub fn with_id( id: Uuid, from: impl Into<String>, to: impl Into<String>, payload: Value, ) -> Self
Sourcepub fn parse_payload(raw: &str) -> Value
pub fn parse_payload(raw: &str) -> Value
Parse JSON when possible; otherwise treat the raw text as a string packet.
pub fn to_json(&self) -> Result<String>
pub fn from_json(line: &str) -> Result<Self>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Envelope
impl<'de> Deserialize<'de> for Envelope
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
impl StructuralPartialEq for Envelope
Auto Trait Implementations§
impl Freeze for Envelope
impl RefUnwindSafe for Envelope
impl Send for Envelope
impl Sync for Envelope
impl Unpin for Envelope
impl UnsafeUnpin for Envelope
impl UnwindSafe for Envelope
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