Struct UnixListener
pub struct UnixListener { /* private fields */ }
Expand description
A Unix (domain) socket server, listening for incoming connections once served
using one of the serve
methods such as UnixListener::serve
.
Note that the underlying socket (file) is only cleaned up
by this listener’s Drop
implementation if the listener
was created using the bind_path
constructor. Otherwise
it is assumed that the creator of this listener is in charge
of that cleanup.
Implementations§
§impl UnixListener
impl UnixListener
pub fn build() -> UnixListenerBuilder
pub fn build() -> UnixListenerBuilder
Create a new UnixListenerBuilder
without a state,
which can be used to configure a UnixListener
.
pub async fn bind_path(path: impl AsRef<Path>) -> Result<UnixListener, Error>
pub async fn bind_path(path: impl AsRef<Path>) -> Result<UnixListener, Error>
Creates a new UnixListener
, which will be bound to the specified path.
The returned listener is ready for accepting connections.
pub fn bind_socket(socket: Socket) -> Result<UnixListener, Error>
pub fn bind_socket(socket: Socket) -> Result<UnixListener, Error>
Creates a new UnixListener
, which will be bound to the specified socket.
The returned listener is ready for accepting connections.
pub async fn bind_socket_opts(
opts: SocketOptions,
) -> Result<UnixListener, Box<dyn Error + Sync + Send>>
pub async fn bind_socket_opts( opts: SocketOptions, ) -> Result<UnixListener, Box<dyn Error + Sync + Send>>
Creates a new TcpListener, which will be bound to the specified (interface) device name.
The returned listener is ready for accepting connections.
§impl UnixListener
impl UnixListener
pub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
Returns the local address that this listener is bound to.
This can be useful, for example, when binding to port 0 to figure out which port was actually bound.
§impl UnixListener
impl UnixListener
pub async fn accept(&self) -> Result<(UnixStream, UnixSocketAddress), Error>
pub async fn accept(&self) -> Result<(UnixStream, UnixSocketAddress), Error>
Accept a single connection from this listener, what you can do with whatever you want.
pub async fn serve<S>(self, service: S)where
S: Service<UnixStream>,
pub async fn serve<S>(self, service: S)where
S: Service<UnixStream>,
Serve connections from this listener with the given service.
This method will block the current listener for each incoming connection, the underlying service can choose to spawn a task to handle the accepted stream.
pub async fn serve_graceful<S>(self, guard: ShutdownGuard, service: S)where
S: Service<UnixStream>,
pub async fn serve_graceful<S>(self, guard: ShutdownGuard, service: S)where
S: Service<UnixStream>,
Serve gracefully connections from this listener with the given service.
This method does the same as Self::serve
but it
will respect the given rama_core::graceful::ShutdownGuard
, and also pass
it to the service.
Trait Implementations§
§impl AsFd for UnixListener
impl AsFd for UnixListener
§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
§impl AsRawFd for UnixListener
impl AsRawFd for UnixListener
§impl Debug for UnixListener
impl Debug for UnixListener
§impl From<UnixListener> for UnixListener
impl From<UnixListener> for UnixListener
§fn from(value: UnixListener) -> UnixListener
fn from(value: UnixListener) -> UnixListener
§impl TryFrom<Socket> for UnixListener
impl TryFrom<Socket> for UnixListener
§impl TryFrom<UnixListener> for UnixListener
impl TryFrom<UnixListener> for UnixListener
§fn try_from(
listener: UnixListener,
) -> Result<UnixListener, <UnixListener as TryFrom<UnixListener>>::Error>
fn try_from( listener: UnixListener, ) -> Result<UnixListener, <UnixListener as TryFrom<UnixListener>>::Error>
Auto Trait Implementations§
impl !Freeze for UnixListener
impl RefUnwindSafe for UnixListener
impl Send for UnixListener
impl Sync for UnixListener
impl Unpin for UnixListener
impl UnwindSafe for UnixListener
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more