Skip to main content

AsyncReadAdapter

Struct AsyncReadAdapter 

Source
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>

Source

pub fn new(inner: S) -> Self

Wrap an inner AsyncRead+AsyncWrite stream.

Source

pub fn get_ref(&self) -> &S

Access the inner stream.

Source

pub fn get_mut(&mut self) -> &mut S

Mutable access to the inner stream.

Source

pub fn into_inner(self) -> S

Decompose into the inner stream.

Trait Implementations§

Source§

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>>

Read bytes into sink.spare(). Returns the number of bytes actually delivered to the sink. Ok(0) indicates EOF. Read more
Source§

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.
Source§

fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Flush bytes previously written via poll_write to the transport. Returns Poll::Ready(Ok(())) once all buffered data has been pushed to the underlying socket. Mirrors tokio::io::AsyncWrite::poll_flush.
Source§

fn poll_shutdown(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<()>>

Shut down the write side of the transport. For TLS-bearing implementations, send close_notify first and flush before closing the underlying connection. Mirrors tokio::io::AsyncWrite::poll_shutdown.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V