Trait SocketService

pub trait SocketService<State>:
    Send
    + Sync
    + 'static {
    type Socket: Send + 'static;
    type Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static;

    // Required method
    fn bind(
        &self,
        ctx: Context<State>,
        interface: impl Into<Interface>,
    ) -> impl Future<Output = Result<(Self::Socket, Context<State>), Self::Error>> + Send;
}
Expand description

Glue trait that is used as the trait bound for code creating/preparing a socket 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 Socket: Send + 'static

Socket returned by the SocketService

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

Error returned in case of connection / setup failure

Required Methods§

fn bind( &self, ctx: Context<State>, interface: impl Into<Interface>, ) -> impl Future<Output = Result<(Self::Socket, Context<State>), Self::Error>> + Send

Create a binding to a Unix/Linux/Windows socket.

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§

§

impl<S, State, Socket> SocketService<State> for S
where S: Service<State, Interface, Response = (Socket, Context<State>)>, <S as Service<State, Interface>>::Error: Into<Box<dyn Error + Send + Sync>> + Send + 'static, Socket: Send + 'static,

§

type Socket = Socket

§

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