Storage

Trait Storage 

Source
pub trait Storage {
    type SetError: IsFatalError;
    type GetError: IsFatalError;

    // Required methods
    fn set(&mut self, key: String, value: Value) -> Result<(), Self::SetError>;
    fn get(&mut self, key: &str) -> Result<Option<Value>, Self::GetError>;
}
Expand description

Specification of interface for accessing configuration.

The configuration can be stored using many different methods. In order to implement a new way of storing configuration data, you must implement this trait for your type.

Required Associated Types§

Source

type SetError: IsFatalError

Error which may occur when attempting to write to the storage.

Source

type GetError: IsFatalError

Error which may occur when attempting to read from the storage.

Required Methods§

Source

fn set(&mut self, key: String, value: Value) -> Result<(), Self::SetError>

When this function is called, the implementor must store the given value for key in the storage or return error in case of failure.

Source

fn get(&mut self, key: &str) -> Result<Option<Value>, Self::GetError>

The implementor must return the value at given key (if exists, None if not) or error if getting fails.

Implementations on Foreign Types§

Source§

impl<T> Storage for Arc<Mutex<T>>
where T: Storage + ?Sized,

Source§

type SetError = SyncOpResult<<T as Storage>::SetError>

Source§

type GetError = SyncOpResult<<T as Storage>::GetError>

Source§

fn set(&mut self, key: String, value: Value) -> Result<(), Self::SetError>

Source§

fn get(&mut self, key: &str) -> Result<Option<Value>, Self::GetError>

Source§

impl<T: Storage + ?Sized> Storage for Box<T>

Source§

type SetError = <T as Storage>::SetError

Source§

type GetError = <T as Storage>::GetError

Source§

fn set(&mut self, key: String, value: Value) -> Result<(), Self::SetError>

Source§

fn get(&mut self, key: &str) -> Result<Option<Value>, Self::GetError>

Implementors§