pub type FileId = u32;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct IndexedSymbol {
pub name: String,
pub kind: String,
pub start_line: u32,
pub end_line: u32,
pub signature: String,
}
#[derive(Debug, Clone)]
pub struct IndexedFile {
pub id: FileId,
pub relative_path: String,
pub language: String,
pub size_bytes: u64,
pub line_count: u32,
pub content_hash: u64,
pub mtime_ms: i64,
pub symbols: Vec<IndexedSymbol>,
pub imports: Vec<String>,
}
pub fn fnv1a64(bytes: &[u8]) -> u64 {
let mut h: u64 = 0xcbf2_9ce4_8422_2325;
for byte in bytes {
h ^= *byte as u64;
h = h.wrapping_mul(0x0000_0100_0000_01b3);
}
h
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn fnv_matches_swift_reference() {
assert_eq!(fnv1a64(b"hello world"), 0x779a_65e7_023c_d2e7);
assert_eq!(fnv1a64(b""), 0xcbf2_9ce4_8422_2325);
}
}