pub struct StorageManager { /* private fields */ }Expand description
High-level storage coordinator.
Wraps a StorageBackend and provides convenience methods.
Implementations§
Source§impl StorageManager
impl StorageManager
pub fn new(backend: Arc<dyn StorageBackend>) -> Self
pub fn platform_id(&self) -> &str
Sourcepub fn get_string(
&self,
ns: &StorageNamespace,
key: &str,
) -> StorageResult<Option<String>>
pub fn get_string( &self, ns: &StorageNamespace, key: &str, ) -> StorageResult<Option<String>>
Get a string value.
Sourcepub fn set_string(
&self,
ns: &StorageNamespace,
key: &str,
value: &str,
) -> StorageResult<()>
pub fn set_string( &self, ns: &StorageNamespace, key: &str, value: &str, ) -> StorageResult<()>
Set a string value.
Sourcepub fn get_bool(
&self,
ns: &StorageNamespace,
key: &str,
) -> StorageResult<Option<bool>>
pub fn get_bool( &self, ns: &StorageNamespace, key: &str, ) -> StorageResult<Option<bool>>
Get a boolean value.
Sourcepub fn get_json<T: DeserializeOwned>(
&self,
ns: &StorageNamespace,
key: &str,
) -> StorageResult<Option<T>>
pub fn get_json<T: DeserializeOwned>( &self, ns: &StorageNamespace, key: &str, ) -> StorageResult<Option<T>>
Get a value, deserializing from JSON stored as a string.
Sourcepub fn set_json<T: Serialize>(
&self,
ns: &StorageNamespace,
key: &str,
value: &T,
) -> StorageResult<()>
pub fn set_json<T: Serialize>( &self, ns: &StorageNamespace, key: &str, value: &T, ) -> StorageResult<()>
Set a value, serializing to JSON and storing as a string.
Sourcepub fn multi_get(
&self,
ns: &StorageNamespace,
keys: &[&str],
) -> StorageResult<HashMap<String, StorageValue>>
pub fn multi_get( &self, ns: &StorageNamespace, keys: &[&str], ) -> StorageResult<HashMap<String, StorageValue>>
Multi-get: fetch multiple keys at once.
Sourcepub fn multi_set(
&self,
ns: &StorageNamespace,
entries: &[(&str, StorageValue)],
) -> StorageResult<()>
pub fn multi_set( &self, ns: &StorageNamespace, entries: &[(&str, StorageValue)], ) -> StorageResult<()>
Multi-set: store multiple key-value pairs at once.
pub fn supports_secure(&self) -> bool
Sourcepub fn secure_set_string(&self, key: &str, value: &str) -> StorageResult<()>
pub fn secure_set_string(&self, key: &str, value: &str) -> StorageResult<()>
Store a string securely.
Sourcepub fn secure_get_string(&self, key: &str) -> StorageResult<Option<String>>
pub fn secure_get_string(&self, key: &str) -> StorageResult<Option<String>>
Retrieve a securely stored string.
Sourcepub fn write_text(&self, path: &str, text: &str) -> StorageResult<()>
pub fn write_text(&self, path: &str, text: &str) -> StorageResult<()>
Write a string to a file.
Sourcepub fn read_text(&self, path: &str) -> StorageResult<String>
pub fn read_text(&self, path: &str) -> StorageResult<String>
Read a file as a UTF-8 string.
Auto Trait Implementations§
impl Freeze for StorageManager
impl !RefUnwindSafe for StorageManager
impl Send for StorageManager
impl Sync for StorageManager
impl Unpin for StorageManager
impl UnsafeUnpin for StorageManager
impl !UnwindSafe for StorageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more