pub trait AsyncTcpStream:
Send
+ Sync
+ Debug {
// Required methods
fn poll_read(
&self,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<usize>>;
fn poll_write(
&self,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>;
fn shutdown_write(&self) -> Result<()>;
fn reset_on_close(&self) -> Result<()>;
fn set_traffic_class(&self, value: u8) -> Result<u32>;
fn local_addr(&self) -> Result<SocketAddr>;
fn peer_addr(&self) -> Result<SocketAddr>;
}Expand description
A TCP connection of a runtime. &self methods: the driver’s reader and writer tasks share
one Arc.
Required Methods§
Sourcefn poll_read(&self, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize>>
fn poll_read(&self, cx: &mut Context<'_>, buf: &mut [u8]) -> Poll<Result<usize>>
Reads into buf; 0 at the peer’s end of stream.
Sourcefn poll_write(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
fn poll_write(&self, cx: &mut Context<'_>, buf: &[u8]) -> Poll<Result<usize>>
Writes some of buf; how much.
Sourcefn shutdown_write(&self) -> Result<()>
fn shutdown_write(&self) -> Result<()>
Sourcefn reset_on_close(&self) -> Result<()>
fn reset_on_close(&self) -> Result<()>
Makes the close abortive (SO_LINGER 0): when the last reference is dropped the
connection is reset (RST) instead of closed with FIN.
§Errors
The socket refused.
Sourcefn set_traffic_class(&self, value: u8) -> Result<u32>
fn set_traffic_class(&self, value: u8) -> Result<u32>
Sets the socket’s TOS / Traffic Class byte and returns what the operating system reports for it afterwards.
§Errors
The platform refused the option or does not offer it.
Sourcefn local_addr(&self) -> Result<SocketAddr>
fn local_addr(&self) -> Result<SocketAddr>
Its local address.
Sourcefn peer_addr(&self) -> Result<SocketAddr>
fn peer_addr(&self) -> Result<SocketAddr>
The peer’s address.
Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".