Struct ockam_core::TransportMessage
source · pub struct TransportMessage {
pub version: ProtocolVersion,
pub onward_route: Route,
pub return_route: Route,
pub payload: Vec<u8>,
pub tracing_context: Option<String>,
}
Expand description
A generic transport message type.
This type is exposed in ockam_core
(and the root ockam
crate) in
order to provide a mechanism for third-party developers to create
custom transport channel routers.
Casual users of Ockam should never have to interact with this type directly.
§Examples
See ockam_transport_tcp::workers::sender::TcpSendWorker
for a usage example.
Fields§
§version: ProtocolVersion
The transport protocol version.
onward_route: Route
Onward message route.
return_route: Route
Return message route.
This field must be populated by routers handling this message along the way.
payload: Vec<u8>
The message payload.
tracing_context: Option<String>
An optional tracing context
Implementations§
source§impl TransportMessage
impl TransportMessage
sourcepub fn latest(
onward_route: impl Into<Route>,
return_route: impl Into<Route>,
payload: Vec<u8>
) -> Self
pub fn latest( onward_route: impl Into<Route>, return_route: impl Into<Route>, payload: Vec<u8> ) -> Self
Create the latest version of a transport message with an empty return route.
sourcepub fn v1(
onward_route: impl Into<Route>,
return_route: impl Into<Route>,
payload: Vec<u8>
) -> Self
pub fn v1( onward_route: impl Into<Route>, return_route: impl Into<Route>, payload: Vec<u8> ) -> Self
Create a transport message in version v1
sourcepub fn new(
version: ProtocolVersion,
onward_route: impl Into<Route>,
return_route: impl Into<Route>,
payload: Vec<u8>,
tracing_context: Option<String>
) -> Self
pub fn new( version: ProtocolVersion, onward_route: impl Into<Route>, return_route: impl Into<Route>, payload: Vec<u8>, tracing_context: Option<String> ) -> Self
Create a new transport message
sourcepub fn decode_message(buf: Vec<u8>) -> Result<TransportMessage>
pub fn decode_message(buf: Vec<u8>) -> Result<TransportMessage>
Decode the transport message according to the first byte, which is the version number
sourcepub fn start_new_tracing_context(
self,
_tracing_context: OpenTelemetryContext
) -> Self
pub fn start_new_tracing_context( self, _tracing_context: OpenTelemetryContext ) -> Self
Return a TransportMessage with a new tracing context:
- A new trace is started
- The previous trace and the new trace are linked together
We start a new trace here in order to make sure that each transport message is always associated to a globally unique trace id and then cannot be correlated with another transport message that would leave the same node for example.
We can still navigate the two created traces as one thanks to their link.
sourcepub fn tracing_context(&self) -> OpenTelemetryContext
pub fn tracing_context(&self) -> OpenTelemetryContext
Return the tracing context
Trait Implementations§
source§impl Clone for TransportMessage
impl Clone for TransportMessage
source§fn clone(&self) -> TransportMessage
fn clone(&self) -> TransportMessage
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TransportMessage
impl Debug for TransportMessage
source§impl Decodable for TransportMessage
impl Decodable for TransportMessage
source§impl Display for TransportMessage
impl Display for TransportMessage
source§impl Encodable for TransportMessage
impl Encodable for TransportMessage
source§impl PartialEq for TransportMessage
impl PartialEq for TransportMessage
source§fn eq(&self, other: &TransportMessage) -> bool
fn eq(&self, other: &TransportMessage) -> bool
self
and other
values to be equal, and is used
by ==
.