pub struct EncoderBuilder { /* private fields */ }
Expand description

A builder to configure and initialize an Encoder.

The fields to encode are opt-in: only the fields enabled through the builder will be extracted from the Record passed to Encoder::push and written to the archive.

For instance, to write a nucleotide archive containing only the sequence and identifier of each record:

let encoder = nafcodec::EncoderBuilder::new(nafcodec::SequenceType::Dna)
    .id(true)
    .sequence(true)
    .with_memory()
    .unwrap();

Implementations§

source§

impl EncoderBuilder

source

pub fn new(sequence_type: SequenceType) -> Self

Create a new encoder builder with default parameters.

source

pub fn from_flags<F: Into<Flags>>(sequence_type: SequenceType, flags: F) -> Self

Create a new encoder builder from the given flags.

This constructor can be used as a shortcut to setup encoding of a subset of supported fields. For instance, to write only the sequence identifiers and quality lines to an archive:

let mut encoder = EncoderBuilder::from_flags(Dna, Flag::Id | Flag::Quality)
    .with_memory()
    .unwrap();
source

pub fn id(&mut self, id: bool) -> &mut Self

Whether or not to encode the identifier of each record.

source

pub fn comment(&mut self, comment: bool) -> &mut Self

Whether or not to encode the comment of each record.

source

pub fn sequence(&mut self, sequence: bool) -> &mut Self

Whether or not to encode the sequence of each record.

source

pub fn quality(&mut self, quality: bool) -> &mut Self

Whether or not to decode the quality of each record.

source

pub fn compression_level(&mut self, level: i32) -> &mut Self

The compression level to use for zstd compression.

Pass 0 to use the default zstd value, otherwise any integer in range 1-22. See zstd::stream::write::Encoder for more information.

source

pub fn with_memory<'z>(&self) -> Result<Encoder<'z, Memory>, Error>

Consume the builder to get an encoder using in-memory storage.

source

pub fn with_storage<'z, S: Storage>( &self, storage: S ) -> Result<Encoder<'z, S>, Error>

Consume the builder to get an encoder using the given storage.

Trait Implementations§

source§

impl Clone for EncoderBuilder

source§

fn clone(&self) -> EncoderBuilder

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EncoderBuilder

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.