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: ProtocolVersionThe transport protocol version.
onward_route: RouteOnward message route.
return_route: RouteReturn 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 with_tracing_context(self, tracing_context: String) -> Self
pub fn with_tracing_context(self, tracing_context: String) -> Self
Specify the tracing context
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 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
impl Eq for TransportMessage
impl Message for TransportMessage
impl StructuralPartialEq for TransportMessage
Auto Trait Implementations§
impl Freeze for TransportMessage
impl RefUnwindSafe for TransportMessage
impl Send for TransportMessage
impl Sync for TransportMessage
impl Unpin for TransportMessage
impl UnwindSafe for TransportMessage
Blanket Implementations§
source§impl<D> AsyncTryClone for D
impl<D> AsyncTryClone for D
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)