WindowedInfinity

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

Trait Implementations§

Source§

impl ErrorType for WindowedInfinity<'_>

Source§

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, Self::Error>

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

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

Flush this output stream, blocking until 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. Read more
Source§

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

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

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