Skip to main content

SessionStorage

Trait SessionStorage 

Source
pub trait SessionStorage: Send {
    // Required methods
    fn metadata(&self) -> SessionMetadata;
    fn get_leaf_id(&self) -> Option<String>;
    fn set_leaf_id(&mut self, leaf_id: Option<&str>) -> Result<(), String>;
    fn create_entry_id(&self) -> String;
    fn append_entry(&mut self, entry: SessionEntry) -> Result<(), String>;
    fn get_entry(&self, id: &str) -> Option<SessionEntry>;
    fn find_entries(&self, type_name: &str) -> Vec<SessionEntry>;
    fn get_label(&self, id: &str) -> Option<String>;
    fn get_path_to_root(
        &self,
        leaf_id: Option<&str>,
    ) -> Result<Vec<SessionEntry>, String>;
    fn get_entries(&self) -> Vec<SessionEntry>;
    fn path(&self) -> Option<&Path>;
}
Expand description

Low-level CRUD abstraction for session persistence.

Pi-compatible: provides leaf management, label tracking, path queries, and entry CRUD. Session builds on this for the high-level API.

Required Methods§

Source

fn metadata(&self) -> SessionMetadata

Return header-derived metadata.

Source

fn get_leaf_id(&self) -> Option<String>

Get the current leaf entry ID (the last non-leaf entry, resolved through leaf entries). Returns None if no entries exist.

Source

fn set_leaf_id(&mut self, leaf_id: Option<&str>) -> Result<(), String>

Persist a leaf entry that records the active session-tree leaf. None means reset to no leaf.

Source

fn create_entry_id(&self) -> String

Generate a unique 8-character hex entry ID, collision-checked.

Source

fn append_entry(&mut self, entry: SessionEntry) -> Result<(), String>

Append a fully-constructed entry. Updates in-memory state and persists to disk.

Source

fn get_entry(&self, id: &str) -> Option<SessionEntry>

Look up an entry by ID.

Source

fn find_entries(&self, type_name: &str) -> Vec<SessionEntry>

Find all entries of the given type string.

Source

fn get_label(&self, id: &str) -> Option<String>

Get the human-readable label for an entry, if any.

Source

fn get_path_to_root( &self, leaf_id: Option<&str>, ) -> Result<Vec<SessionEntry>, String>

Walk from leaf_id (or current leaf, if None) to root, returning entries in path order.

Source

fn get_entries(&self) -> Vec<SessionEntry>

Return all entries in insertion order.

Source

fn path(&self) -> Option<&Path>

The file path on disk, if this storage is file-backed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§