pub trait NameCodec: Sized {
type Decoded;
const TYPE_TAG: [u8; 16];
const LOSSY: bool;
const IS_IDENTITY: bool = false;
// Required methods
fn encode_into(name: &[u8], output: &mut Vec<u8>) -> Result<(), DryIceError>;
fn decode(
encoded: &[u8],
original_len: usize,
) -> Result<Self::Decoded, DryIceError>;
fn as_bytes(decoded: &Self::Decoded) -> &[u8] ⓘ;
// Provided methods
fn encode(name: &[u8]) -> Result<Vec<u8>, DryIceError> { ... }
fn decode_to_bytes_into(
encoded: &[u8],
original_len: usize,
output: &mut Vec<u8>,
) -> Result<(), DryIceError> { ... }
}Expand description
A name encoding strategy for dryice blocks.
Unlike SequenceCodec and
QualityCodec, the name codec
has an associated Decoded type that can carry
richer parsed structure than raw bytes. This reflects the fact
that sequencing record names are structured text with meaningful
subfields.
Required Associated Constants§
Provided Associated Constants§
Sourceconst IS_IDENTITY: bool = false
const IS_IDENTITY: bool = false
Whether the encoded form is identical to the raw input bytes.
Required Associated Types§
Required Methods§
Sourcefn encode_into(name: &[u8], output: &mut Vec<u8>) -> Result<(), DryIceError>
fn encode_into(name: &[u8], output: &mut Vec<u8>) -> Result<(), DryIceError>
Encode raw name bytes, appending the encoded bytes directly into the provided output buffer.
§Errors
Returns an error if the name data is invalid for this encoding.
Provided Methods§
Sourcefn encode(name: &[u8]) -> Result<Vec<u8>, DryIceError>
fn encode(name: &[u8]) -> Result<Vec<u8>, DryIceError>
Encode name bytes, returning a new allocated buffer.
§Errors
Returns an error if the name data is invalid for this encoding.
Sourcefn decode_to_bytes_into(
encoded: &[u8],
original_len: usize,
output: &mut Vec<u8>,
) -> Result<(), DryIceError>
fn decode_to_bytes_into( encoded: &[u8], original_len: usize, output: &mut Vec<u8>, ) -> Result<(), DryIceError>
Decode an encoded buffer directly to raw bytes, appending into the provided output buffer.
This is used internally by the block decoder to populate the
name buffer without requiring knowledge of the Decoded type.
The default implementation decodes and then copies via as_bytes.
§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.