Skip to main content

VersionedFileEntry

Struct VersionedFileEntry 

Source
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: String

File path (relative to engram root)

§file_type: FileType

Type of file (regular, symlink, device, etc.)

§permissions: FilePermissions

Unix 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: bool

Is this a text file? (affects encoding strategy)

§size: usize

Size 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: bool

Is 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: u64

Version number of this file entry

§created_at: Instant

When this file was created

§modified_at: Instant

When this file was last modified

Implementations§

Source§

impl VersionedFileEntry

Source

pub fn new( path: String, is_text: bool, size: usize, chunks: Vec<ChunkId>, ) -> Self

Create a new file entry for a regular file

Source

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

Create a symlink entry

Create a hardlink entry

Source

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 device
  • major - Major device number
  • minor - Minor device number
  • permissions - Unix permissions
  • size - Size of device data (0 for metadata-only)
  • chunks - Chunk IDs for device data (empty for metadata-only)
Source

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.

Source

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)

Source

pub fn new_special( path: String, file_type: FileType, permissions: FilePermissions, ) -> Self

Create a special file entry (FIFO or socket - metadata only)

Source

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

Source

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

Source

pub fn update(&self, new_chunks: Vec<ChunkId>, new_size: usize) -> Self

Create an updated version of this file entry

Source

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

Source

pub fn mark_deleted(&self) -> Self

Mark this file as deleted

Source

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

Source

pub fn is_regular_file(&self) -> bool

Check if this entry represents a regular file with content

Source

pub fn is_metadata_only(&self) -> bool

Check if this entry is metadata-only (no data to encode)

Source

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
Source

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.

Source

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

Source

pub fn has_offset_index(&self) -> bool

Check if this entry has a chunk offset index

Source

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)).

Source

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 file
  • length - Number of bytes to read
§Returns

Vec of ChunkRange for each chunk involved in the read. Returns empty Vec if start_offset >= file size.

Source

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

Source§

fn clone(&self) -> VersionedFileEntry

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VersionedFileEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V