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§
Sourcefn transport_type(&self) -> TransportType
fn transport_type(&self) -> TransportType
Returns the type of this transport.
Sourcefn capabilities(&self) -> &TransportCapabilities
fn capabilities(&self) -> &TransportCapabilities
Returns the capabilities of this transport.
Sourcefn state<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = TransportState> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
Sourcefn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), TransportError>> + 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,
Establishes a connection to the remote endpoint.
Sourcefn disconnect<'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,
Closes the connection to the remote endpoint.
Sourcefn 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 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.
Sourcefn 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 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.
Provided Methods§
Sourcefn is_connected<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
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.
Sourcefn endpoint(&self) -> Option<String>
fn endpoint(&self) -> Option<String>
Returns the endpoint address or identifier for this transport, if applicable.
Sourcefn 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,
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.