Skip to main content

SortKey

Trait SortKey 

Source
pub trait SortKey:
    Ord
    + Clone
    + Send
    + Sync {
    type Context: Clone + Send + Sync;

    // Required methods
    fn build_context(header: &Header) -> Self::Context;
    fn from_record(
        record: &RecordBuf,
        header: &Header,
        ctx: &Self::Context,
    ) -> Result<Self>;
}
Expand description

Trait for sort keys that can be extracted from BAM records.

The Context associated type allows sort keys to pre-compute data from the header once (e.g., library index mapping) and reuse it for each record extraction.

Required Associated Types§

Source

type Context: Clone + Send + Sync

Context built once from header (e.g., LibraryIndex for template-coordinate). Use () for keys that don’t need context.

Required Methods§

Source

fn build_context(header: &Header) -> Self::Context

Build context from header (called once at sort start).

Source

fn from_record( record: &RecordBuf, header: &Header, ctx: &Self::Context, ) -> Result<Self>

Extract a sort key from a BAM record using pre-built context.

§Errors

Returns an error if key extraction fails due to missing or invalid fields.

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§