[][src]Struct windowed_infinity::WindowedInfinity

pub struct WindowedInfinity<'a> { /* fields omitted */ }

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.

The set of traits it implements depends on the configured cargo features:

  • With the std feature, it implements std::io::Write
  • With the with_serde_cbor feature, it uses serde_cbor's trait unsealing feature to implement its Write trait.

Implementations

impl<'a> WindowedInfinity<'a>[src]

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

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.

pub fn get_cursor(&self) -> isize[src]

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.

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

At the current cursor position, insert the given data.

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

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

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

impl<'a> Write for WindowedInfinity<'a>[src]

Auto Trait Implementations

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

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

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

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.