Skip to main content

StorageBackend

Trait StorageBackend 

Source
pub trait StorageBackend:
    Send
    + Sync
    + 'static {
    // Required methods
    fn load(&self, item: &str) -> Result<Option<String>>;
    fn save(&self, item: &str, text: &str) -> Result<()>;
}
Expand description

A program’s own storage for Storage::custom: text items by name ("credentials", "player-token").

Required Methods§

Source

fn load(&self, item: &str) -> Result<Option<String>>

The item’s text, or None if it was never saved.

Source

fn save(&self, item: &str, text: &str) -> Result<()>

Replaces the item’s text.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<L, S> StorageBackend for StorageFn<L, S>
where L: Fn(&str) -> Result<Option<String>> + Send + Sync + 'static, S: Fn(&str, &str) -> Result<()> + Send + Sync + 'static,