Transport

Trait Transport 

Source
pub trait Transport:
    Send
    + Sync
    + Debug {
    // Required methods
    fn transport_type(&self) -> TransportType;
    fn capabilities(&self) -> &TransportCapabilities;
    fn state<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = TransportState> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn connect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn disconnect<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn send<'life0, 'async_trait>(
        &'life0 self,
        message: TransportMessage,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn receive<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<TransportMessage>, TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn metrics<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = TransportMetrics> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn is_connected<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
    fn endpoint(&self) -> Option<String> { ... }
    fn configure<'life0, 'async_trait>(
        &'life0 self,
        config: TransportConfig,
    ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

The core trait for all transport implementations.

This trait defines the essential, asynchronous operations for a message-based communication channel, such as connecting, disconnecting, sending, and receiving.

Required Methods§

Source

fn transport_type(&self) -> TransportType

Returns the type of this transport.

Source

fn capabilities(&self) -> &TransportCapabilities

Returns the capabilities of this transport.

Source

fn state<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportState> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Returns the current state of the transport.

Source

fn connect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Establishes a connection to the remote endpoint.

Source

fn disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Closes the connection to the remote endpoint.

Source

fn send<'life0, 'async_trait>( &'life0 self, message: TransportMessage, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sends a single message over the transport.

Source

fn receive<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<TransportMessage>, TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Receives a single message from the transport in a non-blocking way.

Source

fn metrics<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = TransportMetrics> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Returns a snapshot of the transport’s current performance metrics.

Provided Methods§

Source

fn is_connected<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Returns true if the transport is currently in the Connected state.

Source

fn endpoint(&self) -> Option<String>

Returns the endpoint address or identifier for this transport, if applicable.

Source

fn configure<'life0, 'async_trait>( &'life0 self, config: TransportConfig, ) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Applies a new configuration to the transport.

Implementors§