Trait Stream

Source
pub trait Stream:
    AsyncRead
    + RefTokioAsyncRead
    + AsyncWrite
    + RefTokioAsyncWrite
    + Send
    + Sync
    + Sized
    + Sealed {
    type RecvHalf: RecvHalf<Stream = Self>;
    type SendHalf: SendHalf<Stream = Self>;

    // Required methods
    fn connect(
        name: Name<'_>,
    ) -> impl Future<Output = Result<Self>> + Send + Sync;
    fn split(self) -> (Self::RecvHalf, Self::SendHalf);
    fn reunite(rh: Self::RecvHalf, sh: Self::SendHalf) -> ReuniteResult<Self>;
}
Expand description

Tokio local socket stream implementations.

Types on which this trait is implemented are variants of the Stream enum. In addition, it is implemented on Stream itself, which makes it a trait object of sorts. See its documentation for more on the semantics of the methods seen here.

Required Associated Types§

Source

type RecvHalf: RecvHalf<Stream = Self>

Receive half type returned by .split().

Source

type SendHalf: SendHalf<Stream = Self>

Send half type returned by .split().

Required Methods§

Source

fn connect(name: Name<'_>) -> impl Future<Output = Result<Self>> + Send + Sync

Asynchronously connects to a remote local socket server.

Source

fn split(self) -> (Self::RecvHalf, Self::SendHalf)

Splits a stream into a receive half and a send half, which can be used to receive from and send to the stream concurrently from different Tokio tasks, entailing a memory allocation.

Source

fn reunite(rh: Self::RecvHalf, sh: Self::SendHalf) -> ReuniteResult<Self>

Attempts to reunite a receive half with a send half to yield the original stream back, returning both halves as an error if they belong to different streams (or when using this method on streams that haven’t been split to begin with).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Stream for interprocess::local_socket::tokio::Stream

Source§

impl Stream for interprocess::os::unix::uds_local_socket::tokio::Stream