Skip to main content

UnifyStream

Enum UnifyStream 

Source
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>

Source

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.

Source

pub async fn connect_timeout<A>(addr: &A, timeout: Duration) -> Result<Self>
where IO: AsyncRuntime, A: ResolveAddr + ?Sized,

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 PathBuf
  • timeout - 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.

Source

pub async fn shutdown_write(&mut self) -> Result<()>

Source

pub fn peer_addr(&self) -> Result<SocketAddr>

Trait Implementations§

Source§

impl<IO: AsyncIO> AsyncRead for UnifyStream<IO>

Source§

async fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Async version of read function Read more
Source§

fn read_exact<'a>( &'a mut self, buf: &'a mut [u8], ) -> impl Future<Output = Result<()>> + Send + 'a

Read the exact number of bytes required to fill buf. Read more
Source§

fn read_at_least<'a>( &'a mut self, buf: &'a mut [u8], min_len: usize, ) -> impl Future<Output = Result<usize>> + Send + 'a

Reads at least min_len bytes into buf. Read more
Source§

impl<IO: AsyncIO> AsyncWrite for UnifyStream<IO>

Source§

async fn write(&mut self, buf: &[u8]) -> Result<usize>

Async version of write function Read more
Source§

fn write_all<'a>( &'a mut self, buf: &'a [u8], ) -> impl Future<Output = Result<()>> + Send + 'a

Write the entire buffer buf. Read more
Source§

impl<IO: AsyncIO> Debug for UnifyStream<IO>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.