pub struct Envelope {
pub kind: String,
pub schema: String,
pub version: u32,
pub body: CborBytes,
}Expand description
Envelope carrying a canonical CBOR payload.
Fields§
§kind: StringDomain-specific kind (pack/component/etc.).
schema: StringSchema identifier for the body.
version: u32Schema version for the body.
body: CborBytesCanonical CBOR-encoded payload.
Implementations§
Source§impl Envelope
impl Envelope
Sourcepub fn ensure_canonical(&self) -> Result<()>
pub fn ensure_canonical(&self) -> Result<()>
Ensure the body payload is canonical CBOR.
Source§impl Envelope
impl Envelope
Sourcepub fn new<T: Serialize>(
kind: impl Into<String>,
schema: impl Into<String>,
version: u32,
body: &T,
) -> Result<Self>
pub fn new<T: Serialize>( kind: impl Into<String>, schema: impl Into<String>, version: u32, body: &T, ) -> Result<Self>
Build an envelope from a serializable body, encoding as canonical CBOR.
Sourcepub fn decode_body<T: DeserializeOwned>(&self) -> Result<T>
pub fn decode_body<T: DeserializeOwned>(&self) -> Result<T>
Decode the CBOR body to the requested type.
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 Eq for Envelope
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.