Weave documentation
Rust referencestrand-blobs

strand-blobs · chunk

Source declarations, signatures and documentation for chunk.

Reviewed implementation boundary: The current GC path quarantines records without reclaiming their stored files. Check actual writer/list/report interfaces and partial-write behavior in /libraries/strand-blobs/overview.

Source: sigil/weave/models/strand-blobs/src/chunk.rs. SHA-256: 922445e00ebb641e699d98ef1d8ffc17508ba2ad02d4a7fb07db570279c72ef6.

This reference follows declared source modules, retains conditional attributes, and includes public declarations and implementation methods. Private-module re-exports and trait resolution require the compiler; this is a source reference, not a claim that every listed item is a root import. Function bodies and constant values are omitted.

chunk::ChunkEntry

Entry describing a stored chunk and its reference count

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ChunkEntry {
/// Index of the packed bytes in the data strand

pub index: u64,
/// Packed (stored) size in bytes

pub packed_length: u64,
/// Blake3 hash of the packed bytes

pub packed_hash: [u8; 32],
/// Current reference count across all blobs

pub refcount: u64
}

Source line: 9.

chunk::BlobEntry

Entry mapping a blob id to its metadata position and state

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BlobEntry {
/// Index of the metadata entry in the metadata strand

pub meta_index: u64,
/// Whether a deletion marker has been observed

pub deleted: bool
}

Source line: 25.

chunk::ChunkIndex

Index for tracking chunks and blobs; enables deduplication and GC

pub struct ChunkIndex {

}

Source line: 33.

chunk::ChunkIndex::new

Create a new chunk index

pub fn new() -> Self;

Source line: 43.

chunk::ChunkIndex::snapshot_blobs

Snapshot blob index for external iteration (copy)

pub fn snapshot_blobs(&self) -> Vec<([u8; 32], BlobEntry)>;

Source line: 51.

chunk::ChunkIndex::snapshot_chunks

Snapshot chunk index for external iteration (copy)

pub fn snapshot_chunks(&self) -> Vec<([u8; 32], ChunkEntry)>;

Source line: 59.

chunk::ChunkIndex::find_chunk

Find a chunk by its hash

pub fn find_chunk(&self, hash: &[u8; 32]) -> Option<ChunkEntry>;

Source line: 67.

chunk::ChunkIndex::add_chunk

Add a chunk to the index

pub fn add_chunk(&self, hash: [u8; 32], index: u64, packed_length: u64, packed_hash: [u8; 32]);

Source line: 72.

chunk::ChunkIndex::incr_chunk_refcount

Increase the reference count for a content hash

pub fn incr_chunk_refcount(&self, hash: &[u8; 32], by: u64);

Source line: 85.

chunk::ChunkIndex::decr_chunk_refcount

Decrease the reference count for a content hash

pub fn decr_chunk_refcount(&self, hash: &[u8; 32], by: u64);

Source line: 92.

chunk::ChunkIndex::find_blob

Find blob metadata by ID

pub fn find_blob(&self, id: &[u8; 32]) -> Option<BlobEntry>;

Source line: 99.

chunk::ChunkIndex::add_blob

Add a blob to the index

pub fn add_blob(&self, id: [u8; 32], index: u64);

Source line: 104.

chunk::ChunkIndex::mark_blob_deleted

Mark blob as deleted in index

pub fn mark_blob_deleted(&self, id: &[u8; 32]);

Source line: 115.

chunk::ChunkIndex::remove_blob

Remove blob metadata from the index

pub fn remove_blob(&self, id: &[u8; 32]);

Source line: 122.

chunk::ChunkIndex::unique_chunks

Get total number of unique chunks

pub fn unique_chunks(&self) -> usize;

Source line: 127.

chunk::ChunkIndex::blob_count

Get total number of blobs

pub fn blob_count(&self) -> usize;

Source line: 132.

chunk::ChunkIndex::clear

Clear the index

pub fn clear(&self);

Source line: 137.

chunk::DedupStats

Statistics about deduplication

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DedupStats {
/// Total number of chunks stored

pub total_chunks: u64,
/// Number of unique chunks

pub unique_chunks: usize,
/// Deduplication ratio (0.0 to 1.0)

pub dedup_ratio: f64,
/// Total bytes saved through deduplication

pub bytes_saved: u64,
/// Average chunk size

pub avg_chunk_size: u64
}

Source line: 151.

chunk::DedupStats::calculate

Calculate stats from chunk counts

pub fn calculate(total_chunks: u64, unique_chunks: usize, avg_chunk_size: u64) -> Self;

Source line: 170.

chunk::ChunkMetadata

Metadata for an individual chunk.

This struct is primarily used by unit tests and higher-level tooling to verify that chunks are stored and retrieved correctly. In production it can also be serialised as part of a diagnostic or telemetry payload. Fields are intentionally kept minimal to avoid unnecessary overhead at runtime.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[allow(dead_code)]
pub struct ChunkMetadata {
/// Blake3 hash of the chunk contents (matches the deduplication key).

pub hash: [u8; 32],
/// Original uncompressed size of the chunk in bytes.

pub size: u32,
/// Sequence number of the chunk in the data strand.

pub index: u64
}

Source line: 201.

On this page