pub struct Routed<M>where
M: Message,{ /* private fields */ }
Expand description
A message wrapper that provides message route information.
Workers can accept arbitrary message types, which may not contain information about their routes.
However, the Ockam worker and messaging system already keeps track of this information internally.
This type makes it possible to expose this information to the user, without requiring changes to the user’s message types.
Examples
See ockam_node::WorkerRelay
for a usage example.
Implementations§
source§impl<M> Routed<M>where
M: Message,
impl<M> Routed<M>where
M: Message,
sourcepub fn new(
inner: M,
msg_addr: Address,
src_addr: Address,
local_msg: LocalMessage
) -> Routed<M>
pub fn new( inner: M, msg_addr: Address, src_addr: Address, local_msg: LocalMessage ) -> Routed<M>
Create a new Routed
message wrapper from the given message,
message address and a local message that contains routing
information.
sourcepub fn onward_route(&self) -> Route
pub fn onward_route(&self) -> Route
Return a copy of the onward route for the wrapped message.
sourcepub fn return_route(&self) -> Route
pub fn return_route(&self) -> Route
Return a copy of the full return route for the wrapped message.
sourcepub fn sender(&self) -> Result<Address, Error>
pub fn sender(&self) -> Result<Address, Error>
Return a copy of the sender address for the wrapped message.
sourcepub fn into_local_message(self) -> LocalMessage
pub fn into_local_message(self) -> LocalMessage
Consume the message wrapper and return the underlying local message.
sourcepub fn into_transport_message(self) -> TransportMessage
pub fn into_transport_message(self) -> TransportMessage
Consume the message wrapper and return the underlying transport message.
sourcepub fn local_message(&self) -> &LocalMessage
pub fn local_message(&self) -> &LocalMessage
Return a reference to the underlying local message.
sourcepub fn payload(&self) -> &[u8] ⓘ
pub fn payload(&self) -> &[u8] ⓘ
Return a reference to the underlying transport message’s binary payload.
sourcepub fn take_payload(self) -> Vec<u8> ⓘ
pub fn take_payload(self) -> Vec<u8> ⓘ
Consume the message wrapper and return the underlying transport message’s binary payload.