Transport

Trait Transport 

Source
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 using tokio-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§

Source

type Error: Error + Send + Sync + 'static

The error type produced by this transport.

Required Methods§

Source

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.

Source

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.

Source

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,

Receive raw bytes. Returns None when the connection is closed.

Source

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,

Close the transport.

Implementors§