pub struct VersionedChunk {
pub vector: Arc<SparseVec>,
pub version: u64,
pub created_at: Instant,
pub modified_at: Instant,
pub ref_count: Arc<AtomicU32>,
pub original_size: usize,
pub content_hash: [u8; 8],
}Expand description
A versioned chunk with metadata
Chunks are immutable once created - the SparseVec is wrapped in Arc for zero-copy sharing across threads. Each update creates a new VersionedChunk with an incremented version number.
Fields§
§vector: Arc<SparseVec>The actual VSA-encoded chunk data (immutable, shared)
version: u64Version number of this chunk (local to the chunk)
created_at: InstantWhen this chunk was first created
modified_at: InstantWhen this chunk was last modified
ref_count: Arc<AtomicU32>Reference count - how many files reference this chunk Used for garbage collection and deduplication tracking
original_size: usizeSize of the original data in bytes (before VSA encoding)
content_hash: [u8; 8]Content hash for deduplication (first 8 bytes of SHA256)
Implementations§
Source§impl VersionedChunk
impl VersionedChunk
Sourcepub fn new(
vector: SparseVec,
original_size: usize,
content_hash: [u8; 8],
) -> Self
pub fn new( vector: SparseVec, original_size: usize, content_hash: [u8; 8], ) -> Self
Create a new versioned chunk
Sourcepub fn update(&self, new_vector: SparseVec, new_hash: [u8; 8]) -> Self
pub fn update(&self, new_vector: SparseVec, new_hash: [u8; 8]) -> Self
Create a new version of this chunk with updated data
Sourcepub fn is_unreferenced(&self) -> bool
pub fn is_unreferenced(&self) -> bool
Check if this chunk can be garbage collected
Sourcepub fn time_since_modification(&self) -> Duration
pub fn time_since_modification(&self) -> Duration
Get time since last modification
Trait Implementations§
Source§impl Clone for VersionedChunk
impl Clone for VersionedChunk
Source§fn clone(&self) -> VersionedChunk
fn clone(&self) -> VersionedChunk
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for VersionedChunk
impl RefUnwindSafe for VersionedChunk
impl Send for VersionedChunk
impl Sync for VersionedChunk
impl Unpin for VersionedChunk
impl UnwindSafe for VersionedChunk
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more