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
sourceimpl 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,
onward_route: Route,
return_route: Route
) -> Result<Routed<Self>>
pub fn into_routed(
self,
msg_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
sourceimpl Clone for OckamMessage
impl Clone for OckamMessage
sourcefn clone(&self) -> OckamMessage
fn clone(&self) -> OckamMessage
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<'de> Deserialize<'de> for OckamMessage
impl<'de> Deserialize<'de> for OckamMessage
sourcefn 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
sourceimpl Serialize for OckamMessage
impl Serialize for OckamMessage
impl Message for OckamMessage
Auto Trait Implementations
impl RefUnwindSafe for OckamMessage
impl Send for OckamMessage
impl Sync for OckamMessage
impl Unpin for OckamMessage
impl UnwindSafe for OckamMessage
Blanket Implementations
sourceimpl<D> AsyncTryClone for D where
D: Clone + Sync,
impl<D> AsyncTryClone for D where
D: Clone + Sync,
sourcefn async_try_clone<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
D: 'async_trait,
fn async_try_clone<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
D: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Try cloning a object and return an Err
in case of failure.
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Decodable for T where
T: DeserializeOwned,
impl<T> Decodable for T where
T: DeserializeOwned,
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more