Skip to main content

ConnectorService

Trait ConnectorService 

pub trait ConnectorService<Input>:
    Send
    + Sync
    + 'static {
    type Connection: Send + ExtensionsRef;
    type Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static;

    // Required method
    fn connect(
        &self,
        input: Input,
    ) -> impl Future<Output = Result<EstablishedClientConnection<Self::Connection, Input>, Self::Error>> + Send;
}
Available on crate feature net only.
Expand description

Glue trait that is used as the Connector trait bound for clients establishing a connection on one layer or another.

Can also be manually implemented as an alternative Service trait, but from a Rama POV it is mostly used for UX trait bounds.

Required Associated Types§

type Connection: Send + ExtensionsRef

Connection returned by the ConnectorService

type Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static

Error returned in case of connection / setup failure

Required Methods§

fn connect( &self, input: Input, ) -> impl Future<Output = Result<EstablishedClientConnection<Self::Connection, Input>, Self::Error>> + Send

Establish a connection, which often involves some kind of handshake, or connection revival.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

§

impl<S, Input, Connection> ConnectorService<Input> for S
where S: Service<Input, Output = EstablishedClientConnection<Connection, Input>>, <S as Service<Input>>::Error: Into<Box<dyn Error + Send + Sync>>, Connection: Send + ExtensionsRef,

§

type Connection = Connection

§

type Error = <S as Service<Input>>::Error