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>
impl<'a> WindowedInfinity<'a>
Sourcepub fn new(view: &'a mut [u8], cursor: isize) -> Self
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.
Sourcepub fn cursor(&self) -> isize
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.
pub fn get_cursor(&self) -> isize
Sourcepub fn write(&mut self, data: &[u8])
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.
Sourcepub fn written(&self) -> &[u8]
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.
pub fn get_written(&self) -> &[u8]
Sourcepub fn tee_digest<D: Digest>(self) -> TeeForDigest<'a, D>
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.
Sourcepub fn tee_crc64<'c>(self, crc: &'c Crc<u64>) -> TeeForCrc<'a, 'c, u64>
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.
Sourcepub fn tee_crc32<'c>(self, crc: &'c Crc<u32>) -> TeeForCrc<'a, 'c, u32>
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>
impl<'a> Io for WindowedInfinity<'a>
Source§type Error = Infallible
type Error = Infallible
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§impl<'a> Write for WindowedInfinity<'a>
impl<'a> Write for WindowedInfinity<'a>
Source§fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Error>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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