pub enum UnixOrTcpListener {
Unix(UnixListener),
Tcp(TcpListener),
}
Variants§
Unix(UnixListener)
Tcp(TcpListener)
Implementations§
source§impl UnixOrTcpListener
impl UnixOrTcpListener
sourcepub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
Get the local address of the listener
§Errors
Returns an error on rare cases where the underlying TcpListener
or
UnixListener
couldn’t provide the local address
pub const fn is_unix(&self) -> bool
pub const fn is_tcp(&self) -> bool
sourcepub async fn accept(&self) -> Result<(SocketAddr, UnixOrTcpConnection), Error>
pub async fn accept(&self) -> Result<(SocketAddr, UnixOrTcpConnection), Error>
Accept an incoming connection
§Cancel safety
This function is safe to cancel, as both UnixListener::accept
and
TcpListener::accept
are safe to cancel.
§Errors
Returns an error if the underlying socket couldn’t accept the connection
sourcepub fn poll_accept(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<(SocketAddr, UnixOrTcpConnection), Error>>
pub fn poll_accept( &self, cx: &mut Context<'_>, ) -> Poll<Result<(SocketAddr, UnixOrTcpConnection), Error>>
Poll for an incoming connection
§Cancel safety
This function is safe to cancel, as both UnixListener::poll_accept
and TcpListener::poll_accept
are safe to cancel.
§Errors
Returns an error if the underlying socket couldn’t accept the connection
Trait Implementations§
source§impl From<TcpListener> for UnixOrTcpListener
impl From<TcpListener> for UnixOrTcpListener
source§fn from(listener: TcpListener) -> Self
fn from(listener: TcpListener) -> Self
Converts to this type from the input type.
source§impl From<UnixListener> for UnixOrTcpListener
impl From<UnixListener> for UnixOrTcpListener
source§fn from(listener: UnixListener) -> Self
fn from(listener: UnixListener) -> Self
Converts to this type from the input type.
source§impl TryFrom<TcpListener> for UnixOrTcpListener
impl TryFrom<TcpListener> for UnixOrTcpListener
source§impl TryFrom<UnixListener> for UnixOrTcpListener
impl TryFrom<UnixListener> for UnixOrTcpListener
Auto Trait Implementations§
impl !Freeze for UnixOrTcpListener
impl RefUnwindSafe for UnixOrTcpListener
impl Send for UnixOrTcpListener
impl Sync for UnixOrTcpListener
impl Unpin for UnixOrTcpListener
impl UnwindSafe for UnixOrTcpListener
Blanket Implementations§
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
Mutably borrows from an owned value. Read more