pub trait Transport: Send + 'static {
type Error: Error + Send + Sync + 'static;
// Required methods
fn connect<'life0, 'life1, 'async_trait>(
&'life0 mut self,
url: &'life1 str,
headers: Vec<(String, String)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn send<'life0, 'async_trait>(
&'life0 mut self,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn recv<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A bidirectional message transport.
The default is WebSocket (TungsteniteTransport); MockTransport enables
unit testing without a real server.
§Implementors
TungsteniteTransport– Production WebSocket transport usingtokio-tungstenite. Handles both Text and Binary frames (Vertex AI sends Binary).MockTransport– Deterministic test transport. Records sent data and replays scripted responses. When the queue is empty,recv()pends indefinitely.
Required Associated Types§
Required Methods§
Sourcefn connect<'life0, 'life1, 'async_trait>(
&'life0 mut self,
url: &'life1 str,
headers: Vec<(String, String)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 mut self,
url: &'life1 str,
headers: Vec<(String, String)>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Connect to the given URL with optional headers.
Sourcefn send<'life0, 'async_trait>(
&'life0 mut self,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send<'life0, 'async_trait>(
&'life0 mut self,
data: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send raw bytes.