twitcher 0.5.0

Find template switch mutations in genomic data
use rust_htslib::bcf;

use crate::{
    common::{aligner::InProgress, csv::CSVAuxData},
    vcf::pipeline::clusterizer::phasing::OutputPhasing,
};

pub(super) enum Message {
    /// Records to emit raw and unchanged: non-cluster runs and unresolvable clusters.
    Passthrough(Vec<bcf::Record>),
    /// A single haplotype sub-cluster. Carries its records with the chosen allele index and
    /// the genotype to emit, so the writer can either write the realignment (on a template
    /// switch) or reconstruct per-haplotype biallelic records (on no TS / failed prep).
    Cluster {
        /// `None` when preparation / alignment-start failed → reconstruct directly.
        /// Boxed because `CSVAuxData` is large and most messages do not carry it.
        pending: Option<Box<(InProgress, CSVAuxData)>>,
        records: Vec<(bcf::Record, u32)>,
        phasing: OutputPhasing,
    },
}

impl Message {
    pub(super) const fn passthrough(orig_records: Vec<bcf::Record>) -> Self {
        Self::Passthrough(orig_records)
    }

    pub(super) const fn cluster(
        pending: Option<Box<(InProgress, CSVAuxData)>>,
        records: Vec<(bcf::Record, u32)>,
        phasing: OutputPhasing,
    ) -> Self {
        Self::Cluster {
            pending,
            records,
            phasing,
        }
    }
}