pub struct VersionedFileEntry {Show 17 fields
pub path: String,
pub file_type: FileType,
pub permissions: FilePermissions,
pub symlink_target: Option<String>,
pub hardlink_target: Option<String>,
pub device_id: Option<(u32, u32)>,
pub is_text: bool,
pub size: usize,
pub chunks: Vec<ChunkId>,
pub chunk_offsets: Option<Vec<ChunkOffset>>,
pub deleted: bool,
pub compression_codec: Option<u8>,
pub uncompressed_size: Option<usize>,
pub encoding_format: Option<u8>,
pub version: u64,
pub created_at: Instant,
pub modified_at: Instant,
}Expand description
A versioned file entry in the manifest
Fields§
§path: StringFile path (relative to engram root)
file_type: FileTypeType of file (regular, symlink, device, etc.)
permissions: FilePermissionsUnix permissions (uid, gid, mode)
symlink_target: Option<String>Symlink target path (only for FileType::Symlink)
hardlink_target: Option<String>Hardlink target path (only for FileType::Hardlink)
device_id: Option<(u32, u32)>Device major/minor numbers (only for char/block devices)
is_text: boolIs this a text file? (affects encoding strategy)
size: usizeSize of the file in bytes
chunks: Vec<ChunkId>List of chunk IDs that make up this file
chunk_offsets: Option<Vec<ChunkOffset>>Byte-offset index for range queries (optional for backward compatibility)
When present, enables O(log n) byte-offset lookups instead of sequential scanning. Each entry maps a chunk ID to its byte offset within the file. If None, offsets can be computed from chunk sizes (requires chunk_store access).
deleted: boolIs this file marked as deleted? (soft delete)
compression_codec: Option<u8>Compression codec used (0=None, 1=Zstd, 2=Lz4) None means no compression (backward compatible)
uncompressed_size: Option<usize>Original uncompressed size (for compressed files)
encoding_format: Option<u8>Encoding format version for holographic storage 0 = Legacy (Codebook.project() - ~0% accuracy) 1 = ReversibleVSA (ReversibleVSAEncoder - ~94% accuracy) None = standard VSA encoding (not holographic)
version: u64Version number of this file entry
created_at: InstantWhen this file was created
modified_at: InstantWhen this file was last modified
Implementations§
Source§impl VersionedFileEntry
impl VersionedFileEntry
Sourcepub fn new(
path: String,
is_text: bool,
size: usize,
chunks: Vec<ChunkId>,
) -> Self
pub fn new( path: String, is_text: bool, size: usize, chunks: Vec<ChunkId>, ) -> Self
Create a new file entry for a regular file
Sourcepub fn new_with_metadata(
path: String,
file_type: FileType,
permissions: FilePermissions,
is_text: bool,
size: usize,
chunks: Vec<ChunkId>,
) -> Self
pub fn new_with_metadata( path: String, file_type: FileType, permissions: FilePermissions, is_text: bool, size: usize, chunks: Vec<ChunkId>, ) -> Self
Create a new file entry with full metadata
Sourcepub fn new_symlink(
path: String,
target: String,
permissions: FilePermissions,
) -> Self
pub fn new_symlink( path: String, target: String, permissions: FilePermissions, ) -> Self
Create a symlink entry
Sourcepub fn new_hardlink(
path: String,
target: String,
permissions: FilePermissions,
) -> Self
pub fn new_hardlink( path: String, target: String, permissions: FilePermissions, ) -> Self
Create a hardlink entry
Sourcepub fn new_device(
path: String,
is_char: bool,
major: u32,
minor: u32,
permissions: FilePermissions,
) -> Self
pub fn new_device( path: String, is_char: bool, major: u32, minor: u32, permissions: FilePermissions, ) -> Self
Create a device node entry (Option C: with encoded data)
Option C encodes actual device data for block devices (e.g., loop devices). For most devices in /dev, this will be empty. For block devices with actual content (like a disk image mounted as a loop device), this allows encoding the full device content.
§Arguments
path- Device path (e.g., “/dev/loop0”)is_char- true for character device, false for block devicemajor- Major device numberminor- Minor device numberpermissions- Unix permissionssize- Size of device data (0 for metadata-only)chunks- Chunk IDs for device data (empty for metadata-only)
Sourcepub fn new_device_with_data(
path: String,
is_char: bool,
major: u32,
minor: u32,
permissions: FilePermissions,
size: usize,
chunks: Vec<ChunkId>,
) -> Self
pub fn new_device_with_data( path: String, is_char: bool, major: u32, minor: u32, permissions: FilePermissions, size: usize, chunks: Vec<ChunkId>, ) -> Self
Create a device node entry with data (Option C full encoding)
Use this for block devices that have actual content to encode, such as loop devices or disk images.
Sourcepub fn new_device_compressed(
path: String,
is_char: bool,
major: u32,
minor: u32,
permissions: FilePermissions,
compressed_size: usize,
uncompressed_size: usize,
compression_codec: u8,
chunks: Vec<ChunkId>,
) -> Self
pub fn new_device_compressed( path: String, is_char: bool, major: u32, minor: u32, permissions: FilePermissions, compressed_size: usize, uncompressed_size: usize, compression_codec: u8, chunks: Vec<ChunkId>, ) -> Self
Create a device node with compressed data (Option C)
Sourcepub fn new_special(
path: String,
file_type: FileType,
permissions: FilePermissions,
) -> Self
pub fn new_special( path: String, file_type: FileType, permissions: FilePermissions, ) -> Self
Create a special file entry (FIFO or socket - metadata only)
Sourcepub fn new_compressed(
path: String,
is_text: bool,
compressed_size: usize,
uncompressed_size: usize,
compression_codec: u8,
chunks: Vec<ChunkId>,
) -> Self
pub fn new_compressed( path: String, is_text: bool, compressed_size: usize, uncompressed_size: usize, compression_codec: u8, chunks: Vec<ChunkId>, ) -> Self
Create a new file entry with compression metadata
Sourcepub fn new_compressed_with_metadata(
path: String,
permissions: FilePermissions,
is_text: bool,
compressed_size: usize,
uncompressed_size: usize,
compression_codec: u8,
chunks: Vec<ChunkId>,
) -> Self
pub fn new_compressed_with_metadata( path: String, permissions: FilePermissions, is_text: bool, compressed_size: usize, uncompressed_size: usize, compression_codec: u8, chunks: Vec<ChunkId>, ) -> Self
Create a new file entry with compression and full metadata
Sourcepub fn update(&self, new_chunks: Vec<ChunkId>, new_size: usize) -> Self
pub fn update(&self, new_chunks: Vec<ChunkId>, new_size: usize) -> Self
Create an updated version of this file entry
Sourcepub fn update_compressed(
&self,
new_chunks: Vec<ChunkId>,
compressed_size: usize,
uncompressed_size: usize,
compression_codec: u8,
) -> Self
pub fn update_compressed( &self, new_chunks: Vec<ChunkId>, compressed_size: usize, uncompressed_size: usize, compression_codec: u8, ) -> Self
Create an updated version with new compression settings
Sourcepub fn mark_deleted(&self) -> Self
pub fn mark_deleted(&self) -> Self
Mark this file as deleted
Sourcepub fn new_holographic(
path: String,
is_text: bool,
size: usize,
chunks: Vec<ChunkId>,
encoding_format: u8,
) -> Self
pub fn new_holographic( path: String, is_text: bool, size: usize, chunks: Vec<ChunkId>, encoding_format: u8, ) -> Self
Create a new file entry for holographic storage with encoding format
Sourcepub fn is_regular_file(&self) -> bool
pub fn is_regular_file(&self) -> bool
Check if this entry represents a regular file with content
Sourcepub fn is_metadata_only(&self) -> bool
pub fn is_metadata_only(&self) -> bool
Check if this entry is metadata-only (no data to encode)
Sourcepub fn build_offset_index(&mut self, chunk_sizes: &[usize])
pub fn build_offset_index(&mut self, chunk_sizes: &[usize])
Build the chunk offset index from chunk sizes
This populates chunk_offsets for O(log n) byte-offset lookups.
Call this after creating chunks when you know the sizes.
§Arguments
chunk_sizes- The decoded (original) size of each chunk in order
Sourcepub fn new_with_offsets(
path: String,
is_text: bool,
size: usize,
chunks: Vec<ChunkId>,
chunk_sizes: Vec<usize>,
) -> Self
pub fn new_with_offsets( path: String, is_text: bool, size: usize, chunks: Vec<ChunkId>, chunk_sizes: Vec<usize>, ) -> Self
Create a new file entry with pre-computed chunk offsets
This is the preferred constructor when chunk sizes are known at creation time.
Sourcepub fn new_holographic_with_offsets(
path: String,
is_text: bool,
size: usize,
chunks: Vec<ChunkId>,
chunk_sizes: Vec<usize>,
encoding_format: u8,
) -> Self
pub fn new_holographic_with_offsets( path: String, is_text: bool, size: usize, chunks: Vec<ChunkId>, chunk_sizes: Vec<usize>, encoding_format: u8, ) -> Self
Create a holographic file entry with pre-computed chunk offsets
Sourcepub fn has_offset_index(&self) -> bool
pub fn has_offset_index(&self) -> bool
Check if this entry has a chunk offset index
Sourcepub fn find_chunk_at_offset(
&self,
byte_offset: usize,
) -> Option<(ChunkId, usize)>
pub fn find_chunk_at_offset( &self, byte_offset: usize, ) -> Option<(ChunkId, usize)>
Find the chunk containing a given byte offset
Returns None if the offset is beyond the file size. Uses binary search when offset index is present (O(log n)). Falls back to linear search otherwise (O(n)).
Sourcepub fn chunks_for_range(
&self,
start_offset: usize,
length: usize,
) -> Vec<ChunkRange>
pub fn chunks_for_range( &self, start_offset: usize, length: usize, ) -> Vec<ChunkRange>
Find all chunks needed to satisfy a byte range read
Returns a list of ChunkRange specifying which chunks to read and which portions of each chunk to include.
§Arguments
start_offset- Start byte offset in the filelength- Number of bytes to read
§Returns
Vec of ChunkRange for each chunk involved in the read. Returns empty Vec if start_offset >= file size.
Sourcepub fn computed_size(&self) -> usize
pub fn computed_size(&self) -> usize
Get the total data size covered by all chunks (from offset index)
Returns file size if no offset index, or the computed total from chunks.
Trait Implementations§
Source§impl Clone for VersionedFileEntry
impl Clone for VersionedFileEntry
Source§fn clone(&self) -> VersionedFileEntry
fn clone(&self) -> VersionedFileEntry
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 VersionedFileEntry
impl RefUnwindSafe for VersionedFileEntry
impl Send for VersionedFileEntry
impl Sync for VersionedFileEntry
impl Unpin for VersionedFileEntry
impl UnwindSafe for VersionedFileEntry
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