anor_storage::storage

Struct Storage

Source
pub struct Storage { /* private fields */ }

Implementations§

Source§

impl Storage

Source

pub fn open() -> Self

Opens a storage and loads persisted data

Source

pub fn open_with_config(config: Arc<Config>) -> Self

Opens a storage with specified configuration and loads persisted data

Source

pub fn sync()

Source

pub fn load(&mut self) -> Result<(), String>

Loads persisted data into storage

Source

pub fn flush(&mut self) -> Result<(), String>

Persists storage data

Source

pub fn lock(&self) -> MutexGuard<'_, HashMap<String, StorageItem>>

Returns a guarded lock to access to the storage operations

Source

pub fn global_lock(&self) -> GlobalLock<'_>

Returns a global lock to exclusive thread access to the storage operations

Source

pub fn insert(&self, storage_item: StorageItem)

Inserts an item into the storage If the storage has an item with the key present, the item will be updated

Source

pub fn update(&self, storage_item: StorageItem)

Updates an item into the storage The item will be inserted if the storage does not have an item with the key present

Source

pub fn get(&self, key: &str) -> Option<StorageItem>

Gets an item from the storage corresponding to the key

Source

pub fn remove(&self, key: &str)

Removes an item from the storage

Source

pub fn clear(&self)

Clears the storage, removing all items

Source

pub fn keys(&self) -> Vec<String>

Returns the keys of the stored items

Source

pub fn get_inner_object<T: Decode>(&self, key: &str) -> Option<T>

Returns the inner object of the item corresponding to the key

Source

pub fn update_inner_object<T: Encode>(&self, key: &str, obj: &T) -> bool

Updates the inner object of the item corresponding to the key

Trait Implementations§

Source§

impl Default for Storage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Storage

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.