use std::path::PathBuf;
use std::time::SystemTime;
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
pub type DocId = u32;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Trigram(pub [u8; 3]);
impl Trigram {
pub fn as_bytes(&self) -> &[u8; 3] {
&self.0
}
}
impl std::fmt::Display for Trigram {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", String::from_utf8_lossy(&self.0))
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PostingEntry {
pub doc_id: DocId,
pub positions: Vec<u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct StructuralMeta {
pub doc_type: Option<String>,
pub dates: Vec<NaiveDate>,
pub amounts: Vec<f64>,
pub emails: Vec<String>,
pub entities: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DocRecord {
pub id: DocId,
pub path: PathBuf,
pub mtime: SystemTime,
pub file_hash: u64,
pub title: Option<String>,
pub snippet: String,
pub simhash: u64,
}