windowed_infinity

Struct WindowedInfinity

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

Source§

type Error = Infallible

Error type of all the IO operations on this type.
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>

Source§

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>

Source§

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>

Source§

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>

Source§

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> Freeze for WindowedInfinity<'a>

§

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

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 12 bytes