pub enum DualStream {
Tcp(TcpStream),
Uds(UnixStream),
}Expand description
A stream that can be either a TCP stream or a Unix Domain Socket stream.
This enum provides a unified interface for both TCP and UDS connections, implementing the necessary async I/O traits to work seamlessly with Axum and other async frameworks.
§Examples
use axum_listener::listener::DualListener;
let listener = DualListener::bind("localhost:8080").await.unwrap();
let (stream, _addr) = listener.accept().await.unwrap();
// The stream can be used with Axum or any other async framework
// that works with tokio's AsyncRead + AsyncWrite traits
println!("Accepted connection from: {:?}", _addr);Variants§
Tcp(TcpStream)
A TCP stream for network connections
Uds(UnixStream)
A Unix Domain Socket stream for local inter-process communication
Trait Implementations§
Source§impl AsyncRead for DualStream
impl AsyncRead for DualStream
Source§impl AsyncWrite for DualStream
impl AsyncWrite for DualStream
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Attempt to write bytes from
buf into the object. Read moreSource§fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Attempts to flush the object, ensuring that any buffered data reach
their destination. Read more
Source§fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>
Initiates or attempts to shut down this writer, returning success when
the I/O connection has completely shut down. Read more
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
Like
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Determines if this writer has an efficient
poll_write_vectored
implementation. Read moreSource§impl From<TcpStream> for DualStream
impl From<TcpStream> for DualStream
Source§impl From<UnixStream> for DualStream
Available on Unix only.
impl From<UnixStream> for DualStream
Available on Unix only.
Source§fn from(stream: UnixStream) -> Self
fn from(stream: UnixStream) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !Freeze for DualStream
impl RefUnwindSafe for DualStream
impl Send for DualStream
impl Sync for DualStream
impl Unpin for DualStream
impl UnwindSafe for DualStream
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