Skip to main content

ArraySegmentExt

Trait ArraySegmentExt 

Source
pub trait ArraySegmentExt: Send + Sync {
    // Required methods
    fn write_array_segment<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        array_name: &'life1 str,
        seg_id: u64,
        bytes: &'life2 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn open_array_segment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        array_name: &'life1 str,
        seg_id: u64,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Box<[u8]>>, LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_array_segment<'life0, 'life1, 'async_trait>(
        &'life0 self,
        array_name: &'life1 str,
        seg_id: u64,
    ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Extension trait: write, open, and delete array tile segments backed by pagedb encrypted segment files.

Implementors translate between the generic array segment byte stream (produced by nodedb_array::SegmentWriter) and the pagedb segment page layout.

This trait is object-safe so StorageEngine implementations can return Option<&dyn ArraySegmentExt> via as_array_segment_ext().

Required Methods§

Source

fn write_array_segment<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, array_name: &'life1 str, seg_id: u64, bytes: &'life2 [u8], ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write an array segment for array_name / seg_id.

Chunks the raw segment bytes into 4 KiB pagedb pages, creates a new encrypted segment, and links it under arr/tile/{array_name}/{seg_id}. If a segment already exists under that name it is atomically replaced (old segment is tombstoned and reaped by the next Db::gc_now call).

Source

fn open_array_segment<'life0, 'life1, 'async_trait>( &'life0 self, array_name: &'life1 str, seg_id: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<[u8]>>, LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Open a previously written array segment for array_name / seg_id.

Returns the raw segment bytes in a Box<[u8]>, identical to the bytes passed to write_array_segment. SegmentReader::open can parse them directly.

Returns None if no segment exists under that name.

Source

fn delete_array_segment<'life0, 'life1, 'async_trait>( &'life0 self, array_name: &'life1 str, seg_id: u64, ) -> Pin<Box<dyn Future<Output = Result<(), LiteError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete the array segment for array_name / seg_id.

No-op if no segment exists. The segment file is tombstoned and reaped by the next Db::gc_now cycle.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<V: Vfs + Clone + Send + Sync + 'static> ArraySegmentExt for PagedbStorage<V>
where <V as Vfs>::LockHandle: Sync, <V as Vfs>::File: Sync,