[][src]Struct rubbl_core::io::AligningWriter

pub struct AligningWriter<W: Write> { /* fields omitted */ }

In analogoy with AligningReader, this struct wraps a Write type to equip it with hooks to track its alignment — that is, how many bytes into the stream the write 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<W: Write> AligningWriter<W>[src]

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

Create a new AligningWriter that wraps the argument inner.

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

Consume this struct, returning the underlying inner writer.

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

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

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

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

Write zero 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 write is performed.

Trait Implementations

impl<W: Debug + Write> Debug for AligningWriter<W>[src]

impl<W: Write> Write for AligningWriter<W>[src]

Auto Trait Implementations

impl<W> RefUnwindSafe for AligningWriter<W> where
    W: RefUnwindSafe

impl<W> Send for AligningWriter<W> where
    W: Send

impl<W> Sync for AligningWriter<W> where
    W: Sync

impl<W> Unpin for AligningWriter<W> where
    W: Unpin

impl<W> UnwindSafe for AligningWriter<W> where
    W: 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<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.

impl<W> WriteBytesExt for W where
    W: Write + ?Sized
[src]