Skip to main content

TransportKind

Trait TransportKind 

Source
pub trait TransportKind: Sync {
    // Required methods
    fn schemes(&self) -> &'static [&'static str];
    fn connect(&self, url: &Url) -> Result<Box<dyn Transport>>;
    fn listen(&self, url: &Url) -> Result<Box<dyn Listener>>;
}
Expand description

Factory for a family of transport schemes.

One implementation per transport backend. The implementation advertises which URL schemes it owns and constructs connected Transport handles or Listeners for them.

Required Methods§

Source

fn schemes(&self) -> &'static [&'static str]

URL schemes this kind owns, e.g. ["inproc"] or ["tcp", "tcp+tls"]. Claimed schemes must be in crate::url::KNOWN_SCHEMES.

Source

fn connect(&self, url: &Url) -> Result<Box<dyn Transport>>

Open a connected transport to the peer identified by url.

Source

fn listen(&self, url: &Url) -> Result<Box<dyn Listener>>

Begin listening for inbound connections at the address in url. Transports that cannot listen (client-only) return crate::error::Error::Unsupported.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§