pub struct ContextStorage { /* private fields */ }Expand description
Storage layer for execution contexts.
Implementations§
Source§impl ContextStorage
impl ContextStorage
Sourcepub fn new() -> Result<Self, ContextError>
pub fn new() -> Result<Self, ContextError>
Create a new context storage with the default base directory.
Uses ~/.skill-engine/contexts as the base directory.
Sourcepub fn with_base_dir(base_dir: PathBuf) -> Result<Self, ContextError>
pub fn with_base_dir(base_dir: PathBuf) -> Result<Self, ContextError>
Create a new context storage with a custom base directory.
Sourcepub fn with_backup_count(self, count: usize) -> Self
pub fn with_backup_count(self, count: usize) -> Self
Set the number of backup versions to keep.
Sourcepub fn save(&self, context: &ExecutionContext) -> Result<(), ContextError>
pub fn save(&self, context: &ExecutionContext) -> Result<(), ContextError>
Save a context to storage.
This performs an atomic write (write to temp file, then rename) to prevent corruption from interrupted writes.
Sourcepub fn load(&self, context_id: &str) -> Result<ExecutionContext, ContextError>
pub fn load(&self, context_id: &str) -> Result<ExecutionContext, ContextError>
Load a context from storage.
Sourcepub fn delete(&self, context_id: &str) -> Result<(), ContextError>
pub fn delete(&self, context_id: &str) -> Result<(), ContextError>
Delete a context from storage.
Sourcepub fn list_with_metadata(&self) -> Result<Vec<ContextIndexEntry>, ContextError>
pub fn list_with_metadata(&self) -> Result<Vec<ContextIndexEntry>, ContextError>
List all contexts with their metadata.
Sourcepub fn get_metadata(
&self,
context_id: &str,
) -> Result<ContextIndexEntry, ContextError>
pub fn get_metadata( &self, context_id: &str, ) -> Result<ContextIndexEntry, ContextError>
Get the index entry for a context without loading the full context.
Sourcepub fn export(
&self,
context_id: &str,
output_dir: &Path,
) -> Result<Vec<String>, ContextError>
pub fn export( &self, context_id: &str, output_dir: &Path, ) -> Result<Vec<String>, ContextError>
Export a context and all its parent contexts to a directory.
Sourcepub fn import(&self, file_path: &Path) -> Result<String, ContextError>
pub fn import(&self, file_path: &Path) -> Result<String, ContextError>
Import a context from a file.
Returns the ID of the imported context.
Sourcepub fn import_with_overwrite(
&self,
file_path: &Path,
overwrite: bool,
) -> Result<String, ContextError>
pub fn import_with_overwrite( &self, file_path: &Path, overwrite: bool, ) -> Result<String, ContextError>
Import a context, optionally overwriting if it exists.
Sourcepub fn restore_backup(
&self,
context_id: &str,
version: usize,
) -> Result<(), ContextError>
pub fn restore_backup( &self, context_id: &str, version: usize, ) -> Result<(), ContextError>
Restore a context from a specific backup version.
Sourcepub fn list_backups(
&self,
context_id: &str,
) -> Result<Vec<BackupInfo>, ContextError>
pub fn list_backups( &self, context_id: &str, ) -> Result<Vec<BackupInfo>, ContextError>
List available backup versions for a context.
Sourcepub fn rebuild_index(&self) -> Result<usize, ContextError>
pub fn rebuild_index(&self) -> Result<usize, ContextError>
Rebuild the index by scanning all contexts.
Useful if the index becomes corrupted or out of sync.