pub struct Document {
pub id: Uuid,
pub path_id: Uuid,
pub path: PathBuf,
pub hash: [u8; 32],
pub hierarchical_hash: [u8; 32],
pub mtime: i64,
pub size: u64,
pub mime_type: String,
}Expand description
A document node in the cognitive graph
Represents a single ingested file with its content hash for change detection and deduplication.
Fields§
§id: UuidUnique identifier for this document (BLAKE3-16 of content_hash)
path_id: UuidPath-based identifier for change detection (BLAKE3-16 of canonicalized path)
path: PathBufOriginal file path (relative to watched root)
hash: [u8; 32]BLAKE3 hash of file contents (canonicalized)
hierarchical_hash: [u8; 32]Merkle root of chunks (hierarchical hash)
mtime: i64Last modification time (Unix timestamp)
size: u64File size in bytes
mime_type: StringMIME type (e.g., “application/pdf”, “text/markdown”)
Implementations§
Source§impl Document
impl Document
pub fn new(path: PathBuf, content: &[u8], mtime: i64) -> Self
Sourcepub fn set_hierarchical_hash(&mut self, hash: [u8; 32])
pub fn set_hierarchical_hash(&mut self, hash: [u8; 32])
Update the hierarchical hash (Merkle root of chunks)
Sourcepub fn compute_hierarchical_hash(chunk_hashes: &[[u8; 32]]) -> [u8; 32]
pub fn compute_hierarchical_hash(chunk_hashes: &[[u8; 32]]) -> [u8; 32]
Compute Merkle hash from chunks for provable correctness
Sourcepub fn content_changed(&self, new_content: &[u8]) -> bool
pub fn content_changed(&self, new_content: &[u8]) -> bool
Check if the document content has changed
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Document
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more