Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Send
    + Sync
    + Debug {
    // Required methods
    fn save_fingerprint<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
        fingerprint: &'life2 AnalysisDefFingerprint,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn load_fingerprint<'life0, 'life1, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<Option<AnalysisDefFingerprint>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_fingerprint<'life0, 'life1, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn save_edge<'life0, 'life1, 'async_trait>(
        &'life0 self,
        edge: &'life1 DependencyEdge,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_edges_from<'life0, 'life1, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_edges_to<'life0, 'life1, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete_edges_for<'life0, 'life1, 'async_trait>(
        &'life0 self,
        file_path: &'life1 Path,
    ) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn load_full_graph<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<DependencyGraph, StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn save_full_graph<'life0, 'life1, 'async_trait>(
        &'life0 self,
        graph: &'life1 DependencyGraph,
    ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn name(&self) -> &'static str;
}
Expand description

Abstract storage backend for the incremental update system.

Provides async persistence for fingerprints and dependency edges. Implementations must support both read and write operations, as well as transactional consistency for batch updates.

§Implementors

  • PostgresStorage (Phase 2): Full Postgres backend for CLI deployment
  • D1Storage (Phase 2): Cloudflare D1 backend for edge deployment

§Examples

use thread_flow::incremental::storage::StorageBackend;

async fn example(storage: &dyn StorageBackend) {
    let fp = storage.load_fingerprint(Path::new("src/main.rs")).await;
}

Required Methods§

Source

fn save_fingerprint<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, file_path: &'life1 Path, fingerprint: &'life2 AnalysisDefFingerprint, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persists a fingerprint for the given file path.

Uses upsert semantics: creates a new entry or updates an existing one.

§Arguments
  • file_path - The file this fingerprint belongs to.
  • fingerprint - The fingerprint data to persist.
Source

fn load_fingerprint<'life0, 'life1, 'async_trait>( &'life0 self, file_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Option<AnalysisDefFingerprint>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads the fingerprint for a file, if one exists.

§Arguments
  • file_path - The file to load the fingerprint for.
§Returns

Ok(Some(fp)) if a fingerprint exists, Ok(None) if not found.

Source

fn delete_fingerprint<'life0, 'life1, 'async_trait>( &'life0 self, file_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<bool, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes the fingerprint for a file.

Returns Ok(true) if a fingerprint was deleted, Ok(false) if no fingerprint existed for the path.

Source

fn save_edge<'life0, 'life1, 'async_trait>( &'life0 self, edge: &'life1 DependencyEdge, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persists a dependency edge.

Uses upsert semantics based on the composite key (from, to, from_symbol, to_symbol, dep_type).

Source

fn load_edges_from<'life0, 'life1, 'async_trait>( &'life0 self, file_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads all dependency edges originating from a file.

Source

fn load_edges_to<'life0, 'life1, 'async_trait>( &'life0 self, file_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<Vec<DependencyEdge>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Loads all dependency edges targeting a file.

Source

fn delete_edges_for<'life0, 'life1, 'async_trait>( &'life0 self, file_path: &'life1 Path, ) -> Pin<Box<dyn Future<Output = Result<usize, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Deletes all dependency edges involving a file (as source or target).

Source

fn load_full_graph<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<DependencyGraph, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Loads the complete dependency graph from storage.

This is used during initialization to restore the graph state from the previous session.

Source

fn save_full_graph<'life0, 'life1, 'async_trait>( &'life0 self, graph: &'life1 DependencyGraph, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Persists the complete dependency graph to storage.

This performs a full replacement of the stored graph. Used after graph rebuilds or major updates.

Source

fn name(&self) -> &'static str

Returns the name of this storage backend for observability.

Used in tracing spans and metrics to identify the storage implementation.

Implementors§