Skip to main content

PersistentCacheIo

Trait PersistentCacheIo 

Source
pub trait PersistentCacheIo: Send + Sync {
    // Required methods
    fn write_atomic(&self, key: u64, frame: &[u8]) -> Result<(), IoError>;
    fn remove(&self, key: u64) -> Result<(), IoError>;
    fn clear(&self) -> Result<(), IoError>;
    fn load(&self, key: u64) -> Result<Option<Vec<u8>>, IoError>;
    fn exists(&self, key: u64) -> bool;
}
Expand description

I/O abstraction the worker thread uses to publish and reload persistent cache frames. Production code uses RealPersistentCacheIo; tests inject recording/blocking/failing variants.

Required Methods§

Source

fn write_atomic(&self, key: u64, frame: &[u8]) -> Result<(), IoError>

Atomically write frame for key (write to temp + fsync + rename + dir-sync). Errors are reported as IoError.

Source

fn remove(&self, key: u64) -> Result<(), IoError>

Remove the persistent frame for key, if any. Missing files are OK.

Source

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

Delete every persistent frame in this cache. Used by clear.

Source

fn load(&self, key: u64) -> Result<Option<Vec<u8>>, IoError>

Read the persistent frame for key, if any. Missing files return Ok(None) so the loader can ignore absent entries.

Source

fn exists(&self, key: u64) -> bool

Best-effort: check whether the on-disk frame for key exists.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§