Struct nafcodec::Encoder

source ·
pub struct Encoder<'z, S: Storage> { /* private fields */ }
Expand description

An encoder for Nucleotide Archive Format files.

NAF archives decomposes data into separate content blocks, which means a NAF file can only be written to a file once all the records have been processed. The encoder uses a temporary storage to store the intermediate data, with an abstract interface declared as the Storage trait.

Implementations§

source§

impl<S: Storage> Encoder<'_, S>

source

pub fn push(&mut self, record: &Record) -> Result<(), Error>

Push a Record to the archive.

The records contents are written to the temporary storage used internally by the Encoder, but the Encoder::write method needs to be called once all records have been added to build the final archive.

source

pub fn write<W: Write>(self, file: W) -> Result<(), Error>

Finalize the archive and write it to the given writer.

This method consumes the Encoder, since it cannot receive any additional Record after the compressed blocks have been finalized.

Auto Trait Implementations§

§

impl<'z, S> Freeze for Encoder<'z, S>
where S: Freeze, <S as Storage>::Buffer: Freeze,

§

impl<'z, S> RefUnwindSafe for Encoder<'z, S>

§

impl<'z, S> Send for Encoder<'z, S>
where S: Send, <S as Storage>::Buffer: Send,

§

impl<'z, S> Sync for Encoder<'z, S>
where S: Sync, <S as Storage>::Buffer: Sync,

§

impl<'z, S> Unpin for Encoder<'z, S>
where S: Unpin, <S as Storage>::Buffer: Unpin,

§

impl<'z, S> UnwindSafe for Encoder<'z, S>
where S: UnwindSafe, <S as Storage>::Buffer: UnwindSafe,

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

§

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

§

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.