pub enum UnifyStream<IO: AsyncIO> {
Tcp(TcpStream<IO>),
Unix(UnixStream<IO>),
}Expand description
Unify behavior of tcp & unix stream
Variants§
Tcp(TcpStream<IO>)
Unix(UnixStream<IO>)
Implementations§
Source§impl<IO: AsyncIO> UnifyStream<IO>
impl<IO: AsyncIO> UnifyStream<IO>
Sourcepub async fn connect<A: ResolveAddr + ?Sized>(addr: &A) -> Result<Self>where
IO: AsyncRuntime,
pub async fn connect<A: ResolveAddr + ?Sized>(addr: &A) -> Result<Self>where
IO: AsyncRuntime,
Connect to a unified address asynchronously.
This method attempts to establish a connection to the specified address, automatically determining whether to use TCP or Unix socket based on the address type.
§Parameters
addr- The address to connect to, can be a string, SocketAddr, or PathBuf
§Returns
A future that resolves to a Result containing either the connected
UnifyStream or an I/O error.
Sourcepub async fn connect_timeout<A>(addr: &A, timeout: Duration) -> Result<Self>
pub async fn connect_timeout<A>(addr: &A, timeout: Duration) -> Result<Self>
Connect to a unified address asynchronously with a timeout.
This method attempts to establish a connection to the specified address, automatically determining whether to use TCP or Unix socket based on the address type. If the connection attempt takes longer than the specified timeout, an error will be returned.
§Parameters
addr- The address to connect to, can be a string, SocketAddr, or PathBuftimeout- The maximum time to wait for the connection
§Returns
A future that resolves to a Result containing either the connected
UnifyStream or an I/O error.
pub async fn shutdown_write(&mut self) -> Result<()>
pub fn peer_addr(&self) -> Result<SocketAddr>
Trait Implementations§
Source§impl<IO: AsyncIO> AsyncRead for UnifyStream<IO>
impl<IO: AsyncIO> AsyncRead for UnifyStream<IO>
Source§impl<IO: AsyncIO> AsyncWrite for UnifyStream<IO>
impl<IO: AsyncIO> AsyncWrite for UnifyStream<IO>
Auto Trait Implementations§
impl<IO> Freeze for UnifyStream<IO>
impl<IO> RefUnwindSafe for UnifyStream<IO>where
<IO as AsyncIO>::AsyncFd<TcpStream>: RefUnwindSafe,
<IO as AsyncIO>::AsyncFd<UnixStream>: RefUnwindSafe,
impl<IO> Send for UnifyStream<IO>
impl<IO> Sync for UnifyStream<IO>
impl<IO> Unpin for UnifyStream<IO>
impl<IO> UnsafeUnpin for UnifyStream<IO>where
<IO as AsyncIO>::AsyncFd<TcpStream>: UnsafeUnpin,
<IO as AsyncIO>::AsyncFd<UnixStream>: UnsafeUnpin,
impl<IO> UnwindSafe for UnifyStream<IO>where
<IO as AsyncIO>::AsyncFd<TcpStream>: UnwindSafe,
<IO as AsyncIO>::AsyncFd<UnixStream>: UnwindSafe,
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