Skip to main content

SocketService

Trait SocketService 

Source
pub trait SocketService:
    Send
    + Sync
    + 'static {
    type Socket: Send + 'static;
    type Error: Into<BoxError> + Send + 'static;

    // Required method
    fn bind_socket_with_address(
        &self,
        addr: impl Into<SocketAddress>,
    ) -> impl Future<Output = Result<Self::Socket, Self::Error>> + Send + '_;
}
Available on crate feature std only.
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§

Source

type Socket: Send + 'static

Socket returned by the SocketService

Source

type Error: Into<BoxError> + Send + 'static

Error returned in case of connection / setup failure

Required Methods§

Source

fn bind_socket_with_address( &self, addr: impl Into<SocketAddress>, ) -> impl Future<Output = Result<Self::Socket, 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".

Implementors§

Source§

impl<S, Socket> SocketService for S
where S: Service<SocketAddress, Output = Socket, Error: Into<BoxError> + Send + 'static>, Socket: Send + 'static,