pub trait Stream:
Read
+ RefRead
+ Write
+ RefWrite
+ Send
+ Sync
+ Sized
+ Sealed {
type RecvHalf: RecvHalf<Stream = Self>;
type SendHalf: SendHalf<Stream = Self>;
// Required methods
fn connect(name: Name<'_>) -> Result<Self>;
fn set_nonblocking(&self, nonblocking: bool) -> Result<()>;
fn split(self) -> (Self::RecvHalf, Self::SendHalf);
fn reunite(rh: Self::RecvHalf, sh: Self::SendHalf) -> ReuniteResult<Self>;
}Expand description
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§
Required Methods§
Sourcefn set_nonblocking(&self, nonblocking: bool) -> Result<()>
fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Enables or disables the nonblocking mode for the stream. By default, it is disabled.
In nonblocking mode, receiving and sending immediately returns with the
WouldBlock error in situations when they would normally block
for an uncontrolled amount of time. The specific situations are:
- Receiving is attempted and there is no new data available;
- Sending is attempted and the buffer is full due to the other side not yet having received previously sent data.
Sourcefn split(self) -> (Self::RecvHalf, Self::SendHalf)
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 threads, entailing a memory allocation.
Sourcefn reunite(rh: Self::RecvHalf, sh: Self::SendHalf) -> ReuniteResult<Self>
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.