pub trait TransportStrategy: Send + Sync {
type Error: Error + Send + Sync + 'static;
// Required methods
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn send_no_response<'life0, 'life1, 'async_trait>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn is_connected(&self) -> bool;
fn transport_type(&self) -> TransportType;
}Expand description
Transport strategy trait
All transport implementations must implement this trait to provide a common interface for connecting, sending, and closing connections.
Required Associated Types§
Required Methods§
Sourcefn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connect to the transport endpoint
Sourcefn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send<'life0, 'life1, 'async_trait>(
&'life0 self,
request: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send a request and receive a response
Sourcefn send_no_response<'life0, 'life1, 'async_trait>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn send_no_response<'life0, 'life1, 'async_trait>(
&'life0 self,
data: &'life1 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Send data without expecting a response (fire and forget)
Sourcefn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close the transport connection
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Check if the transport is connected
Sourcefn transport_type(&self) -> TransportType
fn transport_type(&self) -> TransportType
Get the transport type identifier