Skip to main content

PersistenceStore

Trait PersistenceStore 

Source
pub trait PersistenceStore {
    // Required methods
    fn save(&self, sample: &Sample) -> Result<()>;
    fn load(&self, topic: &str) -> Result<Vec<Sample>>;
    fn query_range(
        &self,
        topic: &str,
        start_ns: u64,
        end_ns: u64,
    ) -> Result<Vec<Sample>>;
    fn apply_retention(&self, topic: &str, keep_count: usize) -> Result<()>;
    fn count(&self) -> Result<usize>;
    fn clear(&self) -> Result<()>;

    // Provided method
    fn apply_retention_policy(
        &self,
        topic: &str,
        policy: &RetentionPolicy,
    ) -> Result<()> { ... }
}
Expand description

Persistence store trait

Backend-agnostic interface for storing and retrieving DDS samples.

§Implementations

  • SqliteStore – Default, zero-dependency
  • RocksDbStore – High-performance (feature flag)

Required Methods§

Source

fn save(&self, sample: &Sample) -> Result<()>

Save a sample to persistent storage

Source

fn load(&self, topic: &str) -> Result<Vec<Sample>>

Load all samples for a topic

Source

fn query_range( &self, topic: &str, start_ns: u64, end_ns: u64, ) -> Result<Vec<Sample>>

Query samples within a time range

§Arguments
  • topic – Topic name (supports wildcards: “State/*”)
  • start_ns – Start timestamp (Unix nanoseconds)
  • end_ns – End timestamp (Unix nanoseconds)
Source

fn apply_retention(&self, topic: &str, keep_count: usize) -> Result<()>

Delete old samples to enforce retention policy

§Arguments
  • topic – Topic name
  • keep_count – Number of recent samples to keep
Source

fn count(&self) -> Result<usize>

Get total number of samples stored

Source

fn clear(&self) -> Result<()>

Clear all samples (for testing)

Provided Methods§

Source

fn apply_retention_policy( &self, topic: &str, policy: &RetentionPolicy, ) -> Result<()>

Apply retention policy with optional age/size constraints.

Implementors§