Trait ConnectorService

Source
pub trait ConnectorService<State, Request>:
    Send
    + Sync
    + 'static {
    type Connection;
    type Error: Into<BoxError>;

    // Required method
    fn connect(
        &self,
        ctx: Context<State>,
        req: Request,
    ) -> impl Future<Output = Result<EstablishedClientConnection<Self::Connection, State, Request>, Self::Error>> + Send + '_;
}
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§

Source

type Connection

Connection returned by the ConnectorService

Source

type Error: Into<BoxError>

Error returned in case of connection / setup failure

Required Methods§

Source

fn connect( &self, ctx: Context<State>, req: Request, ) -> impl Future<Output = Result<EstablishedClientConnection<Self::Connection, State, Request>, 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", so this trait is not object safe.

Implementors§

Source§

impl<S, State, Request, Connection> ConnectorService<State, Request> for S
where S: Service<State, Request, Response = EstablishedClientConnection<Connection, State, Request>, Error: Into<BoxError>>,

Source§

type Connection = Connection

Source§

type Error = <S as Service<State, Request>>::Error