Skip to main content

QualityCodec

Trait QualityCodec 

Source
pub trait QualityCodec: Sized {
    const TYPE_TAG: [u8; 16];
    const LOSSY: bool;
    const IS_IDENTITY: bool = false;

    // Required methods
    fn encode_into(
        quality: &[u8],
        output: &mut Vec<u8>,
    ) -> Result<(), DryIceError>;
    fn decode_into(
        encoded: &[u8],
        original_len: usize,
        output: &mut Vec<u8>,
    ) -> Result<(), DryIceError>;

    // Provided methods
    fn encode(quality: &[u8]) -> Result<Vec<u8>, DryIceError> { ... }
    fn decode(
        encoded: &[u8],
        original_len: usize,
    ) -> Result<Vec<u8>, DryIceError> { ... }
}
Expand description

A quality score encoding strategy for dryice blocks.

Implementors define how raw quality score bytes are encoded for on-disk storage and decoded back. The crate provides RawQualityCodec and BinnedQualityCodec as built-in implementations, but users can implement this trait for custom encodings.

Required Associated Constants§

Source

const TYPE_TAG: [u8; 16]

Stable type tag written into block headers.

Source

const LOSSY: bool

Whether this encoding is lossy.

Provided Associated Constants§

Source

const IS_IDENTITY: bool = false

Whether the encoded form is identical to the raw input bytes.

Required Methods§

Source

fn encode_into(quality: &[u8], output: &mut Vec<u8>) -> Result<(), DryIceError>

Encode raw quality score bytes, appending the encoded bytes directly into the provided output buffer.

§Errors

Returns an error if the quality data is invalid for this encoding.

Source

fn decode_into( encoded: &[u8], original_len: usize, output: &mut Vec<u8>, ) -> Result<(), DryIceError>

Decode an encoded buffer, appending the decoded quality bytes directly into the provided output buffer.

original_len is the number of quality scores in the original record, needed because some encodings may compress.

§Errors

Returns an error if the encoded data is corrupt or inconsistent.

Provided Methods§

Source

fn encode(quality: &[u8]) -> Result<Vec<u8>, DryIceError>

Encode quality scores, returning a new allocated buffer.

§Errors

Returns an error if the quality data is invalid for this encoding.

Source

fn decode(encoded: &[u8], original_len: usize) -> Result<Vec<u8>, DryIceError>

Decode an encoded buffer, returning a new allocated buffer.

§Errors

Returns an error if the encoded data is corrupt or inconsistent.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§