Struct ockam::OckamMessage
source · #[non_exhaustive]pub struct OckamMessage {
pub data: Vec<u8>,
pub scope: Vec<Vec<u8>>,
pub generic: Option<Metadata>,
}
Expand description
A message metadata wrapper type
This message wraps around a well-typed Message type, with additional metadata. Metadata is split between the “scope” and “generic” sections.
Scope metadata
This metadata is passed around in a particular metadata scope.
For example, a worker that adds some behaviour to message sending
may chose to embed “scope” metadata. When wrapping this message
in another scope the previously scoped metadata becomes part of
the opaque data
section.
Thus it is not possible to retrieve metadata from a different nested scope!
Generic metadata
When creating an OckamMessage
it’s also possible to attach
generic metadata. This data is passed around for every nested
scope and must be re-attached to the outest-most scope when
peeling a nested message stack.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.data: Vec<u8>
Main data section of this message
scope: Vec<Vec<u8>>
Metadata for this specific scope
generic: Option<Metadata>
Metadata that is carried to the final recipient of the message
Implementations§
source§impl OckamMessage
impl OckamMessage
sourcepub fn new<M: Message>(msg: M) -> Result<Self>
pub fn new<M: Message>(msg: M) -> Result<Self>
Create a new OckamMessage
with the data from msg
.
sourcepub fn from_any(msg: Routed<Any>) -> Result<Self>
pub fn from_any(msg: Routed<Any>) -> Result<Self>
Create a new OckamMessage from an untyped Any message
sourcepub fn into_routed(
self,
msg_addr: Address,
src_addr: Address,
onward_route: Route,
return_route: Route
) -> Result<Routed<Self>>
pub fn into_routed( self, msg_addr: Address, src_addr: Address, onward_route: Route, return_route: Route ) -> Result<Routed<Self>>
Wrap this OckamMessage with a new Routed
message type
sourcepub fn scope_data(self, meta: Vec<u8>) -> Self
pub fn scope_data(self, meta: Vec<u8>) -> Self
Add some metadata to this scope
sourcepub fn generic_data<S: Into<String>>(self, key: S, val: Vec<u8>) -> Self
pub fn generic_data<S: Into<String>>(self, key: S, val: Vec<u8>) -> Self
Add to the generic metadata section
Trait Implementations§
source§impl Clone for OckamMessage
impl Clone for OckamMessage
source§fn clone(&self) -> OckamMessage
fn clone(&self) -> OckamMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more