pub struct WindowedInfinity<'a> { /* private fields */ }
Expand description

A WindowedInfinity represents an infinite writable space. A small section of it is mapped to a &mut u8 to which writes are forwarded; writes to the area outside only advance a cursor.

Implementations§

source§

impl<'a> WindowedInfinity<'a>

source

pub fn new(view: &'a mut [u8], cursor: isize) -> Self

Create a new infinity with the window passed as view. The cursor parameter indicates where (in the index space of the view) the infinity’s write operations should start, and is typically either 0 or negative.

source

pub fn cursor(&self) -> isize

Report the current write cursor position in the index space of the view.

This typically used at the end of an infinity’s life time to see whether the view needs to be truncated before further processing, and whether there was any data discarded after the view.

source

pub fn get_cursor(&self) -> isize

👎Deprecated: Renamed to .cursor()
source

pub fn write(&mut self, data: &[u8])

At the current cursor position, insert the given data.

The operation is always successful, and at least changes the write cursor.

source

pub fn written(&self) -> &[u8]

Obtain the written content inside the window, if any.

The slices could be made to have a longer lifetime if there is demand for that by using the sealingslice crate.

source

pub fn get_written(&self) -> &[u8]

👎Deprecated: Renamed to .written()
source

pub fn tee_digest<D: Digest>(self) -> TeeForDigest<'a, D>

Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some digest::Digest.

The resulting type implements all the same writers as the WindowedInfinity, and offers an into_windowed_and_digest(self) -> (WindowedInfinity, Digest) to get both back after writing as completed.

source

pub fn tee_crc64<'c>(self, crc: &'c Crc<u64>) -> TeeForCrc<'a, 'c, u64>

Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some crc::Digest.

This is limited to u64 CRCs due to https://github.com/mrhooray/crc-rs/issues/79, and indirectly the availability of const traits.

source

pub fn tee_crc32<'c>(self, crc: &'c Crc<u32>) -> TeeForCrc<'a, 'c, u32>

Create a Tee (a T-shaped writer) that writes both to this WindowedInfinity and some crc::Digest.

This is limited to u32 CRCs due to https://github.com/mrhooray/crc-rs/issues/79, and indirectly the availability of const traits.

Trait Implementations§

source§

impl<'a> Io for WindowedInfinity<'a>

§

type Error = Infallible

Error type of all the IO operations on this type.
source§

impl Write for WindowedInfinity<'_>

source§

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

Write a buffer into this writer, returning how many bytes were written. Read more
source§

fn flush(&mut self) -> Result<()>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
1.36.0 · source§

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> Result<usize, Error>

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

fn is_write_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Writer has an efficient write_vectored implementation. Read more
1.0.0 · source§

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

Attempts to write an entire buffer into this writer. Read more
source§

fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>

🔬This is a nightly-only experimental API. (write_all_vectored)
Attempts to write multiple buffers into this writer. Read more
1.0.0 · source§

fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result<(), Error>

Writes a formatted string into this writer, returning any error encountered. Read more
1.0.0 · source§

fn by_ref(&mut self) -> &mut Selfwhere
    Self: Sized,

Creates a “by reference” adapter for this instance of Write. Read more
source§

impl<'a> Write for WindowedInfinity<'a>

source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
source§

impl<'a> Write for WindowedInfinity<'a>

§

type Error = Error

The type of error returned when a write operation fails.
source§

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

Attempts to write an entire buffer into this write.
source§

impl<'a> Write for WindowedInfinity<'a>

§

type Error = Infallible

source§

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

Write the whole byte slice.
source§

impl<'a> Write for WindowedInfinity<'a>

§

type Error = Infallible

source§

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

Write the whole byte slice.
source§

impl<'a> Write for WindowedInfinity<'a>

§

type Error = Infallible

The error type
source§

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

Writes all bytes from data or fails
source§

fn flush(&mut self) -> Result<(), Self::Error>

Flushes all output
source§

impl<'a> Write for WindowedInfinity<'a>

source§

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

Write a buffer into this writer, returning how many bytes were written.
source§

fn flush(&mut self) -> Result<(), Self::Error>

Flush this output stream, ensuring that all intermediately buffered contents reach their destination.
source§

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

Write an entire buffer into this writer.
source§

fn write_fmt(
    &mut self,
    fmt: Arguments<'_>
) -> Result<(), WriteFmtError<Self::Error>>

Write a formatted string into this writer, returning any error encountered.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for WindowedInfinity<'a>

§

impl<'a> Send for WindowedInfinity<'a>

§

impl<'a> Sync for WindowedInfinity<'a>

§

impl<'a> Unpin for WindowedInfinity<'a>

§

impl<'a> !UnwindSafe for WindowedInfinity<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.