use crate::address::SocketAddress;
use rama_core::{Service, error::BoxError};
pub trait SocketService: Send + Sync + 'static {
type Socket: Send + 'static;
type Error: Into<BoxError> + Send + 'static;
fn bind_socket_with_address(
&self,
addr: impl Into<SocketAddress>,
) -> impl Future<Output = Result<Self::Socket, Self::Error>> + Send + '_;
}
impl<S, Socket> SocketService for S
where
S: Service<SocketAddress, Output = Socket, Error: Into<BoxError> + Send + 'static>,
Socket: Send + 'static,
{
type Socket = Socket;
type Error = S::Error;
fn bind_socket_with_address(
&self,
addr: impl Into<SocketAddress>,
) -> impl Future<Output = Result<Self::Socket, Self::Error>> + Send + '_ {
self.serve(addr.into())
}
}