pub struct Envelope {
pub v: u8,
pub t: String,
pub p: Vec<u8>,
}Expand description
A decoded envelope without a closed application-message enum.
Keep the original frame when forwarding: re-encoding this view would discard unknown envelope fields. Debug output deliberately omits the payload.
Fields§
§v: u8Protocol generation.
t: StringApplication-defined wire name, including unknown future names.
p: Vec<u8>Independently CBOR-encoded payload bytes.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn new(
v: u8,
t: impl Into<String>,
payload: &impl Serialize,
) -> Result<Self, WireError>
pub fn new( v: u8, t: impl Into<String>, payload: &impl Serialize, ) -> Result<Self, WireError>
Encode a native payload while retaining an explicit wire name.
Sourcepub fn encode(&self) -> Result<Vec<u8>, WireError>
pub fn encode(&self) -> Result<Vec<u8>, WireError>
Encode just the envelope, preserving its already-encoded payload.
Sourcepub fn decode(bytes: &[u8]) -> Result<Self, WireError>
pub fn decode(bytes: &[u8]) -> Result<Self, WireError>
Decode an envelope without restricting application message names.
Sourcepub fn payload<T: DeserializeOwned>(&self) -> Result<T, WireError>
pub fn payload<T: DeserializeOwned>(&self) -> Result<T, WireError>
Decode the payload as a checked record. Never required for raw routing.
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
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