Struct read_collection::ReadBackChain

source ·
pub struct ReadBackChain<T, U> { /* private fields */ }
Expand description

Adapter to chain together two ReadBacks.

This struct is generally created by calling read_back_chain on a reader. Please see the documentation of read_back_chain for more details.

Implementations§

source§

impl<T, U> ReadBackChain<T, U>

source

pub fn into_inner(self) -> (T, U)

Consumes the ReadBackChain, returning the wrapped readers.

§Examples
use std::io;
use read_collection::ReadBack;

fn main() -> io::Result<()> {
    let mut data1: [u8; 3] = [1, 2, 3];
    let mut data2: [u8; 3] = [4, 5, 6];

    let read_back_chain = data1.as_slice().read_back_chain(data2.as_slice());
    let (data1, data2) = read_back_chain.into_inner();
    Ok(())
}
source

pub fn get_ref(&self) -> (&T, &U)

Gets references to the underlying readers in this ReadBackChain.

§Examples
use std::io;
use read_collection::ReadBack;

fn main() -> io::Result<()> {
    let mut data1: [u8; 3] = [1, 2, 3];
    let mut data2: [u8; 3] = [4, 5, 6];

    let read_back_chain = data1.as_slice().read_back_chain(data2.as_slice());
    let (data1, data2) = read_back_chain.get_ref();
    Ok(())
}
source

pub fn get_mut(&mut self) -> (&mut T, &mut U)

Gets mutable references to the underlying readers in this ReadBackChain.

Care should be taken to avoid modifying the internal I/O state of the underlying readers as doing so may corrupt the internal state of this ReadBackChain.

§Examples
use std::io;
use read_collection::ReadBack;

fn main() -> io::Result<()> {
    let mut data1: [u8; 3] = [1, 2, 3];
    let mut data2: [u8; 3] = [4, 5, 6];

    let mut read_back_chain = data1.as_slice().read_back_chain(data2.as_slice());
    let (data1, data2) = read_back_chain.get_mut();
    Ok(())
}

Trait Implementations§

source§

impl<T: BufReadBack, U: BufReadBack> BufReadBack for ReadBackChain<T, U>

source§

fn read_back_fill_buf(&mut self) -> Result<&[u8]>

Returns the contents of the internal buffer, filling it with more data from the inner reader if it is empty. Read more
source§

fn read_back_consume(&mut self, amt: usize)

Tells this buffer that amt bytes have been consumed from the buffer, so they should no longer be returned in calls to read_back. Read more
source§

fn read_back_until(&mut self, byte: u8, buf: &mut Vec<u8>) -> Result<usize>

Read all bytes into buf until the delimiter byte or the beginning of the reader is reached. Read more
source§

fn read_back_has_data_left(&mut self) -> Result<bool>

Check if the underlying ReadBack has any data left to be read. Read more
source§

fn read_back_skip_until(&mut self, delim: u8) -> Result<usize>

Skip all bytes until the delimiter byte or the beginning is reached. Read more
source§

fn read_back_line(&mut self, dest: &mut String) -> Result<usize>

Read all bytes until a newline (the 0xA byte) is reached, and prepend them to the provided String buffer. Read more
source§

fn read_back_split(self, delim: u8) -> ReadBackSplit<Self>
where Self: Sized,

Returns an iterator over the contents of this reader split on the byte byte. Read more
source§

fn read_back_lines(self) -> RevLines<Self>
where Self: Sized,

Returns an iterator over the lines of this reader. Read more
source§

impl<T: Debug, U: Debug> Debug for ReadBackChain<T, U>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: ReadBack, U: ReadBack> ReadBack for ReadBackChain<T, U>

source§

fn read_back(&mut self, buf: &mut [u8]) -> Result<usize>

Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
source§

fn read_back_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize>

Like Read::read_vectored but it uses rev_read instead of read.
source§

fn read_back_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize>

Read all bytes until the start of the source, placing them into buf. Read more
source§

fn read_back_to_string(&mut self, buf: &mut String) -> Result<usize>

Read all bytes until the start of the source, prepending them to buf (since we’re reading back). Read more
source§

fn read_back_exact(&mut self, buf: &mut [u8]) -> Result<()>

Read back the exact number of bytes required to fill buf. Read more
source§

fn read_back_bytes(self) -> ReadBackBytes<Self>
where Self: Sized,

Transforms this ReadBack instance to an Iterator over its bytes. This can be also seen as “read the bytes of the instance in reverse”. Read more
source§

fn read_back_chain<R: ReadBack>(self, next: R) -> ReadBackChain<Self, R>
where Self: Sized,

Creates an adapter which will chain this stream with another. Read more
source§

fn read_back_take(self, limit: u64) -> ReadBackTake<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. Read more

Auto Trait Implementations§

§

impl<T, U> Freeze for ReadBackChain<T, U>
where T: Freeze, U: Freeze,

§

impl<T, U> RefUnwindSafe for ReadBackChain<T, U>

§

impl<T, U> Send for ReadBackChain<T, U>
where T: Send, U: Send,

§

impl<T, U> Sync for ReadBackChain<T, U>
where T: Sync, U: Sync,

§

impl<T, U> Unpin for ReadBackChain<T, U>
where T: Unpin, U: Unpin,

§

impl<T, U> UnwindSafe for ReadBackChain<T, U>
where T: UnwindSafe, U: 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.