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§
Sourcefn load(&self) -> Result<Option<T>, Error>
fn load(&self) -> Result<Option<T>, Error>
Try to load the object from storage.
If no object exists, return Ok(None).
Sourcefn can_store(&self) -> bool
fn can_store(&self) -> bool
Return true if we have the lock; see StateMgr::can_store
.