Skip to main content

Transport

Trait Transport 

Source
pub trait Transport: Send + Sync {
    // Required methods
    fn supports(&self, endpoint: &Endpoint) -> bool;
    fn dial<'life0, 'life1, 'async_trait>(
        &'life0 self,
        endpoint: &'life1 Endpoint,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn ByteStream>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn listen<'life0, 'life1, 'async_trait>(
        &'life0 self,
        endpoint: &'life1 Endpoint,
    ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TransportListener>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A user supplied way to dial and listen, e.g. in-memory pipes, sockets from another runtime, or a WASI host’s sockets. Crates on karyon_net use it for every endpoint it supports, and their built-in transports for the others. Pair it with a custom endpoint scheme (mem://node-a) or take over a built-in one (tcp://, tls://, quic://).

The returned streams are used as is: no TLS or other layer is added.

Required Methods§

Source

fn supports(&self, endpoint: &Endpoint) -> bool

Whether this transport handles endpoint.

Source

fn dial<'life0, 'life1, 'async_trait>( &'life0 self, endpoint: &'life1 Endpoint, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn ByteStream>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Opens a connection to endpoint.

Source

fn listen<'life0, 'life1, 'async_trait>( &'life0 self, endpoint: &'life1 Endpoint, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn TransportListener>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Starts listening on endpoint.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§