Struct io_tether::Tether

source ·
pub struct Tether<I, T, R> { /* private fields */ }
Expand description

A wrapper type which contains the underlying I/O object, it’s initializer, and resolver.

This in the main type exposed by the library. It implements AsyncRead and AsyncWrite whenever the underlying I/O object implements them.

Calling things like read_buf will result in the I/O automatically reconnecting if an error is detected during the underlying I/O call.

§Note

Currently, there is no way to obtain a reference into the underlying I/O object. And the only way to reclaim the inner I/O type is by calling Tether::into_inner. This is by design, since in the future there may be reason to add unsafe code which cannot be guaranteed if outside callers can obtain references. In the future I may add these as unsafe functions if those cases can be described.

Implementations§

source§

impl<I, T, R> Tether<I, T, R>

source

pub fn new(inner: T, initializer: I, resolver: R) -> Self

Construct a tether object from an existing I/O source

source

pub fn get_resolver(&self) -> &R

Returns a reference to the resolver

source

pub fn get_resolver_mut(&mut self) -> &mut R

Returns a mutable reference to the resolver

source

pub fn get_initializer(&self) -> &I

Returns a reference to the initializer

source

pub fn get_initializer_mut(&mut self) -> &mut I

Returns a mutable reference to the initializer

source

pub fn into_inner(self) -> T

Consume the Tether, and return the underlying I/O type

source

pub fn get_context(&self) -> &Context

Returns a reference to the context

source

pub fn get_context_mut(&mut self) -> &mut Context

Returns a mutable reference to the context

source§

impl<I, T, R> Tether<I, T, R>
where T: TetherIo<I>,

source

pub async fn connect(initializer: I, resolver: R) -> Result<Self, T::Error>

Connect to the I/O source

Invokes TetherIo::connect to establish the connection, the same method which is called when Tether attempts to reconnect.

Trait Implementations§

source§

impl<I, T, R> AsyncRead for Tether<I, T, R>
where T: AsyncRead + TetherIo<I, Error = Error>, I: Unpin, R: TetherResolver<Error = Error>,

source§

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

Attempts to read from the AsyncRead into buf. Read more
source§

impl<I, T, R> AsyncWrite for Tether<I, T, R>
where T: AsyncWrite + TetherIo<I, Error = Error>, I: Unpin, R: TetherResolver<Error = Error>,

source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from buf into the object. Read more
source§

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

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
source§

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

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers. Read more
source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more

Auto Trait Implementations§

§

impl<I, T, R> Freeze for Tether<I, T, R>
where I: Freeze, T: Freeze, R: Freeze,

§

impl<I, T, R> RefUnwindSafe for Tether<I, T, R>

§

impl<I, T, R> Send for Tether<I, T, R>
where I: Send, T: Send, R: Send,

§

impl<I, T, R> Sync for Tether<I, T, R>
where I: Sync, T: Sync, R: Sync,

§

impl<I, T, R> Unpin for Tether<I, T, R>
where I: Unpin, T: Unpin, R: Unpin,

§

impl<I, T, R> UnwindSafe for Tether<I, T, R>
where I: UnwindSafe, T: UnwindSafe, R: 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.