pub struct FileHeader {
pub magic: [u8; 8],
pub version: u32,
pub index_type: String,
pub dim: usize,
pub metric: DistanceMetric,
pub n_vectors: usize,
pub crc32: u32,
}Expand description
The header at the start of every iqdb snapshot file.
The on-disk representation is fixed-width little-endian — see the
module-level docs for the byte-level layout. The Rust struct stores
dim and n_vectors as usize for ergonomic in-memory use; the
reader and writer convert to/from u64 at the wire boundary.
crc32 is the CRC32 of the payload bytes only — it does not
cover the header.
§Examples
use iqdb_persist::{FileHeader, CURRENT_VERSION, MAGIC};
use iqdb_types::DistanceMetric;
let header = FileHeader {
magic: MAGIC,
version: CURRENT_VERSION,
index_type: "flat".to_string(),
dim: 128,
metric: DistanceMetric::Cosine,
n_vectors: 1_000,
crc32: 0xDEADBEEF,
};
assert_eq!(header.index_type, "flat");Fields§
§magic: [u8; 8]Magic bytes — always equal to MAGIC.
version: u32On-disk format version. The reader accepts any version in
MIN_SUPPORTED_VERSION..=CURRENT_VERSION and records which one it
read here, so the payload can be decoded per that version.
index_type: StringStable index-type tag — matched against
crate::Persistable::INDEX_TYPE on load.
dim: usizeDimensionality of the vectors stored in the payload.
metric: DistanceMetricDistance metric the index was built for.
n_vectors: usizeNumber of vectors stored in the payload.
crc32: u32CRC32 of the payload bytes (not of the header).
Trait Implementations§
Source§impl Clone for FileHeader
impl Clone for FileHeader
Source§fn clone(&self) -> FileHeader
fn clone(&self) -> FileHeader
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileHeader
impl Debug for FileHeader
impl Eq for FileHeader
Source§impl PartialEq for FileHeader
impl PartialEq for FileHeader
Source§fn eq(&self, other: &FileHeader) -> bool
fn eq(&self, other: &FileHeader) -> bool
self and other values to be equal, and is used by ==.