pub struct AsyncReadAdapter<S> { /* private fields */ }Expand description
Wraps a tokio::io::AsyncRead + AsyncWrite source as a WireStream.
Use this when constructing WsStream/HttpConnection over a custom
tokio transport (raw TcpStream, mock streams, etc.). The canonical
MaybeTls transport implements WireStream directly.
ⓘ
use nexus_async_net::AsyncReadAdapter;
let tcp = tokio::net::TcpStream::connect(addr).await?;
let ws = WsStreamBuilder::new()
.connect_with(AsyncReadAdapter::new(tcp), url)
.await?;Implementations§
Source§impl<S> AsyncReadAdapter<S>
impl<S> AsyncReadAdapter<S>
Trait Implementations§
Source§impl<S: AsyncRead + AsyncWrite + Unpin> WireStream for AsyncReadAdapter<S>
Available on crate feature tokio-rt only.
impl<S: AsyncRead + AsyncWrite + Unpin> WireStream for AsyncReadAdapter<S>
Available on crate feature
tokio-rt only.Source§fn poll_fill_into<P: ParserSink>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
sink: &mut P,
max: usize,
) -> Poll<Result<usize>>
fn poll_fill_into<P: ParserSink>( self: Pin<&mut Self>, cx: &mut Context<'_>, sink: &mut P, max: usize, ) -> Poll<Result<usize>>
Read bytes into
sink.spare(). Returns the number of bytes
actually delivered to the sink. Ok(0) indicates EOF. Read moreSource§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize>>
Write
buf to the transport. Returns the number of bytes
accepted (may be less than buf.len()). Ok(0) may indicate
the transport cannot accept more right now or that the
underlying connection has been closed for writes — same
semantics as tokio::io::AsyncWrite::poll_write. Implementors
of new transports should mirror that contract.Auto Trait Implementations§
impl<S> Freeze for AsyncReadAdapter<S>where
S: Freeze,
impl<S> RefUnwindSafe for AsyncReadAdapter<S>where
S: RefUnwindSafe,
impl<S> Send for AsyncReadAdapter<S>where
S: Send,
impl<S> Sync for AsyncReadAdapter<S>where
S: Sync,
impl<S> Unpin for AsyncReadAdapter<S>where
S: Unpin,
impl<S> UnsafeUnpin for AsyncReadAdapter<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for AsyncReadAdapter<S>where
S: UnwindSafe,
Blanket Implementations§
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