use std::collections::HashMap;
use std::sync::Arc;
use anyhow::{anyhow, Result};
use crate::transcripts::models::{Exon, ManeStatus, Strand, Transcript};
pub(crate) const MAGIC: &[u8; 4] = b"RFTX";
pub(crate) const VERSION: u32 = 2;
pub(crate) const HEADER_SIZE: usize = 40;
pub(crate) const INDEX_ENTRY_SIZE: usize = 16;
pub(crate) const NONE_SENTINEL: u32 = 0xFFFFFFFF;
pub enum TxBytes {
InMemory(Arc<Vec<u8>>),
#[cfg(feature = "filesystem")]
Mmap(memmap2::Mmap),
#[cfg(feature = "filesystem")]
Pread(super::mmap::PreadSource),
}
impl TxBytes {
#[inline]
pub(crate) fn len(&self) -> usize {
match self {
TxBytes::InMemory(buf) => buf.len(),
#[cfg(feature = "filesystem")]
TxBytes::Mmap(mmap) => mmap.len(),
#[cfg(feature = "filesystem")]
TxBytes::Pread(p) => p.len(),
}
}
#[inline]
pub(crate) fn read_at(&self, offset: usize, len: usize) -> Option<Vec<u8>> {
match self {
TxBytes::InMemory(buf) => buf.get(offset..offset.checked_add(len)?).map(<[u8]>::to_vec),
#[cfg(feature = "filesystem")]
TxBytes::Mmap(mmap) => mmap
.get(offset..offset.checked_add(len)?)
.map(<[u8]>::to_vec),
#[cfg(feature = "filesystem")]
TxBytes::Pread(p) => p.read_at(offset, len),
}
}
#[inline]
pub(crate) fn read_u64_le(&self, offset: usize) -> Option<u64> {
match self {
TxBytes::InMemory(buf) => {
let s = buf.get(offset..offset.checked_add(8)?)?;
Some(u64::from_le_bytes(s.try_into().ok()?))
}
#[cfg(feature = "filesystem")]
TxBytes::Mmap(mmap) => {
let s = mmap.get(offset..offset.checked_add(8)?)?;
Some(u64::from_le_bytes(s.try_into().ok()?))
}
#[cfg(feature = "filesystem")]
TxBytes::Pread(p) => {
let buf = p.read_at(offset, 8)?;
Some(u64::from_le_bytes(buf.as_slice().try_into().ok()?))
}
}
}
}
pub(crate) struct ReftxHeader {
pub(crate) record_count: u64,
pub(crate) index_offset: u64,
pub(crate) mane_index_offset: u64,
}
pub(crate) fn parse_header(bytes: &TxBytes) -> Result<ReftxHeader> {
if bytes.len() < HEADER_SIZE {
return Err(anyhow!("File too small for header"));
}
let head = bytes
.read_at(0, HEADER_SIZE)
.ok_or_else(|| anyhow!("Failed to read header"))?;
if &head[0..4] != MAGIC {
return Err(anyhow!("Invalid magic number: expected RFTX"));
}
let version = u32::from_le_bytes(head[4..8].try_into()?);
if version != VERSION {
return Err(anyhow!("Unsupported format version: {}", version));
}
let record_count = u64::from_le_bytes(head[8..16].try_into()?);
let index_offset = u64::from_le_bytes(head[16..24].try_into()?);
let mane_index_offset = u64::from_le_bytes(head[24..32].try_into()?);
Ok(ReftxHeader {
record_count,
index_offset,
mane_index_offset,
})
}
pub struct ReadonlyTxStore {
bytes: TxBytes,
record_count: u64,
index_offset: u64,
mane_index_offset: u64,
transcript_cache: HashMap<u64, Transcript>,
}
impl ReadonlyTxStore {
pub fn from_bytes(bytes: Vec<u8>) -> Result<Self> {
let buf = TxBytes::InMemory(Arc::new(bytes));
Self::from_byte_source(buf)
}
pub(crate) fn from_byte_source(bytes: TxBytes) -> Result<Self> {
let header = parse_header(&bytes)?;
let mut store = Self {
bytes,
record_count: header.record_count,
index_offset: header.index_offset,
mane_index_offset: header.mane_index_offset,
transcript_cache: HashMap::new(),
};
if store.record_count < 500_000 {
store.predecode_all();
}
Ok(store)
}
#[cfg(feature = "filesystem")]
pub(crate) fn from_parts(
bytes: TxBytes,
record_count: u64,
index_offset: u64,
mane_index_offset: u64,
transcript_cache: HashMap<u64, Transcript>,
) -> Self {
Self {
bytes,
record_count,
index_offset,
mane_index_offset,
transcript_cache,
}
}
fn predecode_all(&mut self) {
let idx_start = self.index_offset as usize;
for i in 0..self.record_count as usize {
let entry_offset = idx_start + i * INDEX_ENTRY_SIZE;
let hash = match self.bytes.read_u64_le(entry_offset) {
Some(h) => h,
None => break,
};
let record_offset = match self.bytes.read_u64_le(entry_offset + 8) {
Some(o) => o as usize,
None => break,
};
let next_bound = self.index_offset as usize;
if let Some(tx) = read_record(&self.bytes, record_offset, next_bound) {
self.transcript_cache.insert(hash, tx);
}
}
}
#[inline]
pub fn len(&self) -> u64 {
self.record_count
}
#[inline]
pub fn is_empty(&self) -> bool {
self.record_count == 0
}
pub fn lookup(&self, accession: &str) -> Option<TranscriptRef<'_>> {
let hash = fnv1a_64(accession.as_bytes());
if let Some(tx) = self.transcript_cache.get(&hash)
&& tx.accession == accession
{
return Some(TranscriptRef::Cached(tx));
}
self.lookup_from_bytes(accession, hash)
.map(TranscriptRef::Owned)
}
pub fn lookup_mane(&self, gene: &str) -> Option<Transcript> {
if self.mane_index_offset == 0 {
return None;
}
let bytes = &self.bytes;
let record_bound = self.index_offset as usize;
let normalized = gene.to_uppercase();
let hash = fnv1a_64(normalized.as_bytes());
let idx_base = self.mane_index_offset as usize;
let mane_count = bytes.read_u64_le(idx_base)? as usize;
let idx_start = idx_base + 8;
let mut lo = 0usize;
let mut hi = mane_count;
while lo < hi {
let mid = lo + (hi - lo) / 2;
let entry_offset = idx_start + mid * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
match entry_hash.cmp(&hash) {
std::cmp::Ordering::Less => lo = mid + 1,
std::cmp::Ordering::Greater => hi = mid,
std::cmp::Ordering::Equal => {
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.gene.to_uppercase() == normalized {
return Some(tx);
}
return mane_linear_probe(
bytes,
idx_start,
mane_count,
record_bound,
&normalized,
hash,
mid,
);
}
}
}
None
}
#[inline]
pub fn has_mane_index(&self) -> bool {
self.mane_index_offset != 0
}
fn lookup_from_bytes(&self, accession: &str, hash: u64) -> Option<Transcript> {
let bytes = &self.bytes;
let idx_start = self.index_offset as usize;
let record_bound = self.index_offset as usize;
let count = self.record_count as usize;
let mut lo = 0usize;
let mut hi = count;
while lo < hi {
let mid = lo + (hi - lo) / 2;
let entry_offset = idx_start + mid * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
match entry_hash.cmp(&hash) {
std::cmp::Ordering::Less => lo = mid + 1,
std::cmp::Ordering::Greater => hi = mid,
std::cmp::Ordering::Equal => {
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.accession == accession {
return Some(tx);
}
return linear_probe(
bytes,
self.index_offset,
record_bound,
accession,
hash,
mid,
count,
);
}
}
}
None
}
}
pub(crate) fn read_record(
bytes: &TxBytes,
offset: usize,
record_bound: usize,
) -> Option<Transcript> {
if offset > record_bound {
return None;
}
let window = record_bound - offset;
let data = bytes.read_at(offset, window)?;
let data = data.as_slice();
let mut pos = 0;
let acc_len = *data.get(pos)? as usize;
pos += 1;
let accession = std::str::from_utf8(data.get(pos..pos + acc_len)?)
.ok()?
.to_string();
pos += acc_len;
let gene_len = *data.get(pos)? as usize;
pos += 1;
let gene = std::str::from_utf8(data.get(pos..pos + gene_len)?)
.ok()?
.to_string();
pos += gene_len;
let mut chrom_digest = [0u8; 24];
chrom_digest.copy_from_slice(data.get(pos..pos + 24)?);
pos += 24;
let strand = Strand::from_i8(*data.get(pos)? as i8)?;
pos += 1;
let mane = ManeStatus::from_flags_byte(*data.get(pos)?);
pos += 1;
let cds_start_raw = u32::from_le_bytes(data.get(pos..pos + 4)?.try_into().ok()?);
pos += 4;
let cds_end_raw = u32::from_le_bytes(data.get(pos..pos + 4)?.try_into().ok()?);
pos += 4;
let cds_start = if cds_start_raw == NONE_SENTINEL {
None
} else {
Some(cds_start_raw)
};
let cds_end = if cds_end_raw == NONE_SENTINEL {
None
} else {
Some(cds_end_raw)
};
let exon_count = u16::from_le_bytes(data.get(pos..pos + 2)?.try_into().ok()?) as usize;
pos += 2;
let mut exons = Vec::with_capacity(exon_count);
for _ in 0..exon_count {
let start = u32::from_le_bytes(data.get(pos..pos + 4)?.try_into().ok()?);
pos += 4;
let end = u32::from_le_bytes(data.get(pos..pos + 4)?.try_into().ok()?);
pos += 4;
exons.push(Exon { start, end });
}
Some(Transcript {
accession,
gene,
chrom_digest,
strand,
cds_start,
cds_end,
exons,
mane,
})
}
fn mane_linear_probe(
bytes: &TxBytes,
idx_start: usize,
count: usize,
record_bound: usize,
gene_upper: &str,
hash: u64,
start_idx: usize,
) -> Option<Transcript> {
for i in (start_idx + 1)..count {
let entry_offset = idx_start + i * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
if entry_hash != hash {
break;
}
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.gene.to_uppercase() == gene_upper {
return Some(tx);
}
}
for i in (0..start_idx).rev() {
let entry_offset = idx_start + i * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
if entry_hash != hash {
break;
}
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.gene.to_uppercase() == gene_upper {
return Some(tx);
}
}
None
}
pub(crate) fn linear_probe(
bytes: &TxBytes,
index_offset: u64,
record_bound: usize,
accession: &str,
hash: u64,
start_idx: usize,
count: usize,
) -> Option<Transcript> {
let idx_start = index_offset as usize;
for i in (start_idx + 1)..count {
let entry_offset = idx_start + i * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
if entry_hash != hash {
break;
}
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.accession == accession {
return Some(tx);
}
}
for i in (0..start_idx).rev() {
let entry_offset = idx_start + i * INDEX_ENTRY_SIZE;
let entry_hash = bytes.read_u64_le(entry_offset)?;
if entry_hash != hash {
break;
}
let record_offset = bytes.read_u64_le(entry_offset + 8)? as usize;
let tx = read_record(bytes, record_offset, record_bound)?;
if tx.accession == accession {
return Some(tx);
}
}
None
}
pub enum TranscriptRef<'a> {
Cached(&'a Transcript),
Owned(Transcript),
}
impl<'a> std::ops::Deref for TranscriptRef<'a> {
type Target = Transcript;
fn deref(&self) -> &Self::Target {
match self {
TranscriptRef::Cached(tx) => tx,
TranscriptRef::Owned(tx) => tx,
}
}
}
#[inline]
pub(crate) fn fnv1a_64(data: &[u8]) -> u64 {
const FNV_OFFSET: u64 = 0xcbf29ce484222325;
const FNV_PRIME: u64 = 0x100000001b3;
let mut hash = FNV_OFFSET;
for &byte in data {
hash ^= byte as u64;
hash = hash.wrapping_mul(FNV_PRIME);
}
hash
}
pub(crate) fn serialize_record_into(buf: &mut Vec<u8>, tx: &Transcript) -> Result<()> {
buf.clear();
if tx.accession.len() > u8::MAX as usize {
return Err(anyhow!(
"accession {:?} is {} bytes; exceeds 255-byte .reftx limit",
tx.accession,
tx.accession.len()
));
}
if tx.gene.len() > u8::MAX as usize {
return Err(anyhow!(
"gene {:?} is {} bytes; exceeds 255-byte .reftx limit",
tx.gene,
tx.gene.len()
));
}
buf.push(tx.accession.len() as u8);
buf.extend_from_slice(tx.accession.as_bytes());
buf.push(tx.gene.len() as u8);
buf.extend_from_slice(tx.gene.as_bytes());
buf.extend_from_slice(&tx.chrom_digest);
buf.push(tx.strand.to_byte());
buf.push(tx.mane.to_flags_byte());
buf.extend_from_slice(&tx.cds_start.unwrap_or(NONE_SENTINEL).to_le_bytes());
buf.extend_from_slice(&tx.cds_end.unwrap_or(NONE_SENTINEL).to_le_bytes());
let exon_count: u16 = tx.exons.len().try_into().map_err(|_| {
anyhow!(
"transcript {:?} has {} exons; exceeds {}-exon .reftx limit",
tx.accession,
tx.exons.len(),
u16::MAX
)
})?;
buf.extend_from_slice(&exon_count.to_le_bytes());
for exon in &tx.exons {
buf.extend_from_slice(&exon.start.to_le_bytes());
buf.extend_from_slice(&exon.end.to_le_bytes());
}
Ok(())
}
pub(crate) fn build_reftx_bytes(transcripts: &[Transcript]) -> Result<Vec<u8>> {
let mut sorted: Vec<&Transcript> = transcripts.iter().collect();
sorted.sort_by_key(|t| fnv1a_64(t.accession.as_bytes()));
let mut out = vec![0u8; HEADER_SIZE];
let mut index_entries: Vec<(u64, u64)> = Vec::with_capacity(sorted.len());
let mut mane_entries: Vec<(u64, u64)> = Vec::new();
let mut current_offset = HEADER_SIZE as u64;
let mut record_buf = Vec::with_capacity(512);
for tx in &sorted {
let hash = fnv1a_64(tx.accession.as_bytes());
index_entries.push((hash, current_offset));
if tx.mane.mane_select {
let gene_hash = fnv1a_64(tx.gene.to_uppercase().as_bytes());
mane_entries.push((gene_hash, current_offset));
}
serialize_record_into(&mut record_buf, tx)?;
current_offset += record_buf.len() as u64;
out.extend_from_slice(&record_buf);
}
let index_offset = current_offset;
for (hash, offset) in &index_entries {
out.extend_from_slice(&hash.to_le_bytes());
out.extend_from_slice(&offset.to_le_bytes());
}
let mane_index_offset = if mane_entries.is_empty() {
0u64
} else {
mane_entries.sort_by_key(|(h, _)| *h);
let off = out.len() as u64;
out.extend_from_slice(&(mane_entries.len() as u64).to_le_bytes());
for (hash, offset) in &mane_entries {
out.extend_from_slice(&hash.to_le_bytes());
out.extend_from_slice(&offset.to_le_bytes());
}
off
};
out[0..4].copy_from_slice(MAGIC);
out[4..8].copy_from_slice(&VERSION.to_le_bytes());
out[8..16].copy_from_slice(&(sorted.len() as u64).to_le_bytes());
out[16..24].copy_from_slice(&index_offset.to_le_bytes());
out[24..32].copy_from_slice(&mane_index_offset.to_le_bytes());
Ok(out)
}
pub fn build_reftx_bytes_in_memory(transcripts: &[Transcript]) -> Result<Vec<u8>> {
build_reftx_bytes(transcripts)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_fnv1a_64_deterministic() {
let hash1 = fnv1a_64(b"NM_004333.6");
let hash2 = fnv1a_64(b"NM_004333.6");
assert_eq!(hash1, hash2);
let hash3 = fnv1a_64(b"NM_000546.6");
assert_ne!(hash1, hash3);
}
fn build_reftx_bytes_ok(transcripts: &[Transcript]) -> Vec<u8> {
super::build_reftx_bytes(transcripts).unwrap()
}
fn sample_transcript() -> Transcript {
Transcript {
accession: "NM_004333.6".to_string(),
gene: "BRAF".to_string(),
chrom_digest: [1u8; 24],
strand: Strand::Forward,
cds_start: Some(100),
cds_end: Some(400),
exons: vec![Exon { start: 50, end: 500 }],
mane: ManeStatus {
mane_select: true,
mane_clinical: false,
},
}
}
#[test]
fn test_from_bytes_round_trip_lookup() {
let bytes = build_reftx_bytes_ok(&[sample_transcript()]);
let store = ReadonlyTxStore::from_bytes(bytes).unwrap();
assert_eq!(store.len(), 1);
let tx = store.lookup("NM_004333.6").expect("must find transcript");
assert_eq!(tx.gene, "BRAF");
assert_eq!(tx.exons.len(), 1);
assert!(matches!(tx.strand, Strand::Forward));
assert!(store.lookup("NM_NONEXISTENT.1").is_none());
}
#[test]
fn test_from_bytes_mane_lookup() {
let mut other = sample_transcript();
other.accession = "NM_OTHER.1".to_string();
other.gene = "OTHER".to_string();
other.mane = Default::default();
let bytes = build_reftx_bytes_ok(&[sample_transcript(), other]);
let store = ReadonlyTxStore::from_bytes(bytes).unwrap();
assert!(store.has_mane_index());
let tx = store.lookup_mane("BRAF").expect("MANE BRAF must resolve");
assert_eq!(tx.accession, "NM_004333.6");
assert!(tx.mane.mane_select);
assert_eq!(store.lookup_mane("braf").unwrap().accession, "NM_004333.6");
assert!(store.lookup_mane("OTHER").is_none());
assert!(store.lookup_mane("MISSING").is_none());
}
#[test]
fn test_from_bytes_invalid_magic() {
let mut bytes = build_reftx_bytes_ok(&[sample_transcript()]);
bytes[0] = b'X';
assert!(ReadonlyTxStore::from_bytes(bytes).is_err());
}
#[test]
fn test_n_to_g_zero_returns_error_not_panic() {
use crate::transcripts::mapper::{CoordinateMapper, MappingError};
let bytes = build_reftx_bytes_ok(&[sample_transcript()]);
let store = ReadonlyTxStore::from_bytes(bytes).unwrap();
let mapper = CoordinateMapper::new(&store);
let result = mapper.n_to_g("NM_004333.6", 0);
assert!(matches!(result, Err(MappingError::OutsideTranscript(0))));
}
#[test]
fn test_serialize_record_rejects_oversized_accession() {
let mut tx = sample_transcript();
tx.accession = "A".repeat(256); let mut buf = Vec::new();
assert!(serialize_record_into(&mut buf, &tx).is_err());
}
#[test]
fn test_serialize_record_rejects_oversized_gene() {
let mut tx = sample_transcript();
tx.gene = "G".repeat(256);
let mut buf = Vec::new();
assert!(serialize_record_into(&mut buf, &tx).is_err());
}
#[test]
fn test_serialize_record_accepts_max_length() {
let mut tx = sample_transcript();
tx.accession = "A".repeat(255);
tx.gene = "G".repeat(255);
let mut buf = Vec::new();
assert!(serialize_record_into(&mut buf, &tx).is_ok());
}
#[test]
fn test_build_reftx_bytes_propagates_length_error() {
let mut tx = sample_transcript();
tx.accession = "A".repeat(300);
assert!(super::build_reftx_bytes(&[tx]).is_err());
}
#[test]
fn test_decode_external_golden_fixture() {
#[rustfmt::skip]
let fixture: &[u8] = &[
0x52, 0x46, 0x54, 0x58, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x4e, 0x4d, 0x5f, 0x31, 0x2e, 0x31, 0x01, 0x47, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x01, 0x01, 0x64, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0xa1, 0x1a, 0xf1, 0xdd, 0xe4, 0x0a, 0xd6, 0x3f,
0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x86, 0x1f, 0x02, 0x86, 0x4c, 0xfa, 0x63, 0xaf,
0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
let store = ReadonlyTxStore::from_bytes(fixture.to_vec())
.expect("hand-built fixture must decode");
assert_eq!(store.len(), 1);
let tx = store.lookup("NM_1.1").expect("must find NM_1.1");
assert_eq!(tx.gene, "G");
assert_eq!(tx.chrom_digest, [0x07u8; 24]);
assert!(matches!(tx.strand, Strand::Forward));
assert!(tx.mane.mane_select);
assert_eq!(tx.cds_start, Some(100));
assert_eq!(tx.cds_end, Some(200));
assert_eq!(tx.exons.len(), 1);
assert_eq!(tx.exons[0].start, 10);
assert_eq!(tx.exons[0].end, 20);
assert_eq!(store.lookup_mane("g").unwrap().accession, "NM_1.1");
}
#[test]
fn test_shared_encoder_matches_golden_layout() {
let tx = Transcript {
accession: "NM_1.1".to_string(),
gene: "G".to_string(),
chrom_digest: [0x07u8; 24],
strand: Strand::Forward,
cds_start: Some(100),
cds_end: Some(200),
exons: vec![Exon { start: 10, end: 20 }],
mane: ManeStatus {
mane_select: true,
mane_clinical: false,
},
};
let produced = super::build_reftx_bytes(&[tx]).unwrap();
#[rustfmt::skip]
let fixture: Vec<u8> = vec![
0x52, 0x46, 0x54, 0x58, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x5d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x6d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x06, 0x4e, 0x4d, 0x5f, 0x31, 0x2e, 0x31, 0x01,
0x47, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x01, 0x01, 0x64, 0x00, 0x00, 0x00, 0xc8,
0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x00, 0x00,
0x00, 0x14, 0x00, 0x00, 0x00, 0xa1, 0x1a, 0xf1,
0xdd, 0xe4, 0x0a, 0xd6, 0x3f, 0x28, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x1f, 0x02,
0x86, 0x4c, 0xfa, 0x63, 0xaf, 0x28, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00,
];
assert_eq!(produced, fixture, "shared encoder drifted from golden layout");
}
}