[][src]Struct rubbl_core::io::AligningReader

pub struct AligningReader<R: Read> { /* fields omitted */ }

This struct wraps a Read type to equip it with hooks to track its alignment — that is, how many bytes into the stream the read has progressed, and whether the current offset is an exact multiple of a certain number of bytes from the beginning.

Streams often have alignment requirements so that they can safely be mapped into in-memory data structures. In particular, this is the case for MIRIAD files.

Implementations

impl<R: Read> AligningReader<R>[src]

pub fn new(inner: R) -> Self[src]

Create a new AligningReader that wraps the argument inner.

pub fn into_inner(self) -> R[src]

Consume this struct, returning the underlying inner reader.

pub fn offset(&self) -> u64[src]

Return how many bytes we have read since this struct was created.

Note that this offset is tracked internally. If you open a file, read part of it, and then create an AligningReader, the returned offset will refer to the number of bytes read since creation, not the actual file position as understood by the underlying OS.

pub fn align_to(&mut self, alignment: usize) -> Result<bool>[src]

Read and discard bytes to ensure that the stream is aligned as specified.

The maximum allowed alignment value is 64 bytes.

Returns whether the stream was already at the right alignment. When that is the case, no read is performed.

Trait Implementations

impl<R: Debug + Read> Debug for AligningReader<R>[src]

impl<R: Read> Read for AligningReader<R>[src]

Auto Trait Implementations

impl<R> RefUnwindSafe for AligningReader<R> where
    R: RefUnwindSafe

impl<R> Send for AligningReader<R> where
    R: Send

impl<R> Sync for AligningReader<R> where
    R: Sync

impl<R> Unpin for AligningReader<R> where
    R: Unpin

impl<R> UnwindSafe for AligningReader<R> where
    R: UnwindSafe

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<R> EofReadExactExt for R where
    R: Read
[src]

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

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

impl<R> ReadBytesExt for R where
    R: Read + ?Sized
[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.