pub struct TcpStream { /* private fields */ }Expand description
Native async TCP stream with statistics tracking
Implementations§
Source§impl TcpStream
impl TcpStream
Sourcepub async fn connect(addr: &str) -> Result<TcpStream, Error>
pub async fn connect(addr: &str) -> Result<TcpStream, Error>
Connect to a remote address asynchronously.
addr is a literal socket address or host:port; hostnames resolve off
the polling thread (see resolve). Each resolved address is tried in
order and the first successful connection is returned. Neither
resolution nor the TCP handshake blocks the polling thread, so wrapping
this future in crate::timeout() or dropping it bounds the wait.
§Errors
Returns the resolution error, or the connect error of the last address tried when none accepts.
Sourcepub fn from_std(stream: TcpStream) -> Result<TcpStream, Error>
pub fn from_std(stream: TcpStream) -> Result<TcpStream, Error>
Wrap an existing TCP stream in the Moirai TCP facade.
Sourcepub fn peer_addr(&self) -> Result<SocketAddr, Error>
pub fn peer_addr(&self) -> Result<SocketAddr, Error>
Get the peer address
Sourcepub fn local_addr(&self) -> Result<SocketAddr, Error>
pub fn local_addr(&self) -> Result<SocketAddr, Error>
Get the local address
Trait Implementations§
Source§impl AsyncWrite for TcpStream
impl AsyncWrite for TcpStream
Source§fn poll_write(
self: Pin<&mut TcpStream>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut TcpStream>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from the buffer to the destination.
Source§fn poll_flush(
self: Pin<&mut TcpStream>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut TcpStream>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempt to flush pending writes.
Source§fn poll_shutdown(
self: Pin<&mut TcpStream>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut TcpStream>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Attempt to close/shutdown the write side of the stream.
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
Attempt to write bytes from several buffers in one operation. Read more
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
Whether
poll_write_vectored is cheaper
than one poll_write per buffer.Auto Trait Implementations§
impl Freeze for TcpStream
impl RefUnwindSafe for TcpStream
impl Send for TcpStream
impl Sync for TcpStream
impl Unpin for TcpStream
impl UnsafeUnpin for TcpStream
impl UnwindSafe for TcpStream
Blanket Implementations§
Source§impl<R> AsyncReadExt for R
impl<R> AsyncReadExt for R
Source§impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for Wwhere
W: AsyncWrite + ?Sized,
Source§fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
fn write<'a>(&'a mut self, buf: &'a [u8]) -> Write<'a, Self> ⓘwhere
Self: Unpin,
Write some bytes asynchronously.
Source§fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
fn write_all<'a>(&'a mut self, buf: &'a [u8]) -> WriteAll<'a, Self> ⓘwhere
Self: Unpin,
Write all bytes asynchronously.
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