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

source

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.

source

pub fn v1( onward_route: impl Into<Route>, return_route: impl Into<Route>, payload: Vec<u8> ) -> Self

Create a transport message in version v1

source

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

source

pub fn decode_message(buf: Vec<u8>) -> Result<TransportMessage>

Decode the transport message according to the first byte, which is the version number

source

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.

source

pub fn tracing_context(&self) -> OpenTelemetryContext

Return the tracing context

Trait Implementations§

source§

impl Clone for TransportMessage

source§

fn clone(&self) -> TransportMessage

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for TransportMessage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Decodable for TransportMessage

source§

fn decode(slice: &[u8]) -> Result<Self>

Decode a slice.
source§

impl Display for TransportMessage

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Encodable for TransportMessage

source§

fn encode(self) -> Result<Encoded>

Encode the type into an Encoded type.
source§

impl PartialEq for TransportMessage

source§

fn eq(&self, other: &TransportMessage) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for TransportMessage

source§

impl Message for TransportMessage

source§

impl StructuralPartialEq for TransportMessage

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<D> AsyncTryClone for D
where D: Clone + Sync,

source§

fn async_try_clone<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<D, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, D: 'async_trait,

Try cloning a object and return an Err in case of failure.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more