Trait tor_persist::StorageHandle

source ·
pub trait StorageHandle<T: Serialize + DeserializeOwned> {
    // Required methods
    fn load(&self) -> Result<Option<T>, Error>;
    fn store(&self, val: &T) -> Result<(), Error>;
    fn can_store(&self) -> bool;
}
Expand description

A handle to a storage system that stores objects of a single type to a single location.

To get an object of this type, call StateMgr::create_handle.

Unlike StateMgr, this trait is object-safe.

Required Methods§

source

fn load(&self) -> Result<Option<T>, Error>

Try to load the object from storage.

If no object exists, return Ok(None).

source

fn store(&self, val: &T) -> Result<(), Error>

Try to store a value into storage.

source

fn can_store(&self) -> bool

Return true if we have the lock; see StateMgr::can_store.

Implementors§