pub trait MutinyStorage: Clone + Sized + 'static {
Show 29 methods // Required methods fn password(&self) -> Option<&str>; fn cipher(&self) -> Option<Cipher>; fn vss_client(&self) -> Option<Arc<MutinyVssClient>>; fn set<T>(&self, key: impl AsRef<str>, value: T) -> Result<(), MutinyError> where T: Serialize; fn get<T>(&self, key: impl AsRef<str>) -> Result<Option<T>, MutinyError> where T: for<'de> Deserialize<'de>; fn delete(&self, keys: &[impl AsRef<str>]) -> Result<(), MutinyError>; async fn start(&mut self) -> Result<(), MutinyError>; fn stop(&self); fn connected(&self) -> Result<bool, MutinyError>; fn scan_keys( &self, prefix: &str, suffix: Option<&str> ) -> Result<Vec<String>, MutinyError>; fn change_password( &mut self, new: Option<String>, new_cipher: Option<Cipher> ) -> Result<(), MutinyError>; async fn import(json: Value) -> Result<(), MutinyError>; async fn clear() -> Result<(), MutinyError>; // Provided methods fn set_data<T>( &self, key: impl AsRef<str>, value: T, version: Option<u32> ) -> Result<(), MutinyError> where T: Serialize { ... } fn get_data<T>( &self, key: impl AsRef<str> ) -> Result<Option<T>, MutinyError> where T: for<'de> Deserialize<'de> { ... } fn scan<T>( &self, prefix: &str, suffix: Option<&str> ) -> Result<HashMap<String, T>, MutinyError> where T: for<'de> Deserialize<'de> { ... } fn insert_mnemonic( &self, mnemonic: Mnemonic ) -> Result<Mnemonic, MutinyError> { ... } fn get_mnemonic(&self) -> Result<Option<Mnemonic>, MutinyError> { ... } fn change_password_and_rewrite_storage( &mut self, old: Option<String>, new: Option<String> ) -> Result<(), MutinyError> { ... } async fn delete_all(&self) -> Result<(), MutinyError> { ... } fn get_nodes(&self) -> Result<NodeStorage, MutinyError> { ... } fn insert_nodes(&self, nodes: NodeStorage) -> Result<(), MutinyError> { ... } fn get_fee_estimates( &self ) -> Result<Option<HashMap<String, f64>>, MutinyError> { ... } fn insert_fee_estimates( &self, fees: HashMap<String, f64> ) -> Result<(), MutinyError> { ... } fn has_done_first_sync(&self) -> Result<bool, MutinyError> { ... } fn set_done_first_sync(&self) -> Result<(), MutinyError> { ... } fn get_device_id(&self) -> Result<String, MutinyError> { ... } fn get_device_lock(&self) -> Result<Option<DeviceLock>, MutinyError> { ... } fn set_device_lock(&self) -> Result<(), MutinyError> { ... }
}

Required Methods§

source

fn password(&self) -> Option<&str>

Get the password used to encrypt the storage

source

fn cipher(&self) -> Option<Cipher>

Get the encryption key used for storage

source

fn vss_client(&self) -> Option<Arc<MutinyVssClient>>

Get the VSS client used for storage

source

fn set<T>(&self, key: impl AsRef<str>, value: T) -> Result<(), MutinyError>where T: Serialize,

Set a value in the storage, the value will already be encrypted if needed

source

fn get<T>(&self, key: impl AsRef<str>) -> Result<Option<T>, MutinyError>where T: for<'de> Deserialize<'de>,

Get a value from the storage, use get_data if you want the value to be decrypted

source

fn delete(&self, keys: &[impl AsRef<str>]) -> Result<(), MutinyError>

Delete a set of values from the storage

source

async fn start(&mut self) -> Result<(), MutinyError>

Start the storage, this will be called before any other methods

source

fn stop(&self)

Stop the storage, this will be called when the application is shutting down

source

fn connected(&self) -> Result<bool, MutinyError>

Check if the storage is connected

source

fn scan_keys( &self, prefix: &str, suffix: Option<&str> ) -> Result<Vec<String>, MutinyError>

Scan the storage for keys with a given prefix and suffix, this will return a list of keys If this function does not properly filter the keys, it can cause major problems.

source

fn change_password( &mut self, new: Option<String>, new_cipher: Option<Cipher> ) -> Result<(), MutinyError>

source

async fn import(json: Value) -> Result<(), MutinyError>

Override the storage with the new JSON object

source

async fn clear() -> Result<(), MutinyError>

Deletes all data from the storage

Provided Methods§

source

fn set_data<T>( &self, key: impl AsRef<str>, value: T, version: Option<u32> ) -> Result<(), MutinyError>where T: Serialize,

Set a value in the storage, the function will encrypt the value if needed

source

fn get_data<T>(&self, key: impl AsRef<str>) -> Result<Option<T>, MutinyError>where T: for<'de> Deserialize<'de>,

Get a value from the storage, the function will decrypt the value if needed

source

fn scan<T>( &self, prefix: &str, suffix: Option<&str> ) -> Result<HashMap<String, T>, MutinyError>where T: for<'de> Deserialize<'de>,

Scan the storage for keys with a given prefix and suffix, and then gets their values

source

fn insert_mnemonic(&self, mnemonic: Mnemonic) -> Result<Mnemonic, MutinyError>

Insert a mnemonic into the storage

source

fn get_mnemonic(&self) -> Result<Option<Mnemonic>, MutinyError>

Get the mnemonic from the storage

source

fn change_password_and_rewrite_storage( &mut self, old: Option<String>, new: Option<String> ) -> Result<(), MutinyError>

source

async fn delete_all(&self) -> Result<(), MutinyError>

Deletes all data from the storage and removes lock from VSS

source

fn get_nodes(&self) -> Result<NodeStorage, MutinyError>

Gets the node indexes from storage

source

fn insert_nodes(&self, nodes: NodeStorage) -> Result<(), MutinyError>

Inserts the node indexes into storage

source

fn get_fee_estimates(&self) -> Result<Option<HashMap<String, f64>>, MutinyError>

Get the current fee estimates from storage The key is block target, the value is the fee in satoshis per byte

source

fn insert_fee_estimates( &self, fees: HashMap<String, f64> ) -> Result<(), MutinyError>

Inserts the fee estimates into storage The key is block target, the value is the fee in satoshis per byte

source

fn has_done_first_sync(&self) -> Result<bool, MutinyError>

source

fn set_done_first_sync(&self) -> Result<(), MutinyError>

source

fn get_device_id(&self) -> Result<String, MutinyError>

source

fn get_device_lock(&self) -> Result<Option<DeviceLock>, MutinyError>

source

fn set_device_lock(&self) -> Result<(), MutinyError>

Implementations on Foreign Types§

source§

impl MutinyStorage for ()

source§

fn password(&self) -> Option<&str>

source§

fn cipher(&self) -> Option<Cipher>

source§

fn vss_client(&self) -> Option<Arc<MutinyVssClient>>

source§

fn set<T>(&self, _key: impl AsRef<str>, _value: T) -> Result<(), MutinyError>where T: Serialize,

source§

fn get<T>(&self, _key: impl AsRef<str>) -> Result<Option<T>, MutinyError>where T: for<'de> Deserialize<'de>,

source§

fn delete(&self, _keys: &[impl AsRef<str>]) -> Result<(), MutinyError>

source§

async fn start(&mut self) -> Result<(), MutinyError>

source§

fn stop(&self)

source§

fn connected(&self) -> Result<bool, MutinyError>

source§

fn scan_keys( &self, _prefix: &str, _suffix: Option<&str> ) -> Result<Vec<String>, MutinyError>

source§

fn change_password( &mut self, _new: Option<String>, _new_cipher: Option<Cipher> ) -> Result<(), MutinyError>

source§

async fn import(_json: Value) -> Result<(), MutinyError>

source§

async fn clear() -> Result<(), MutinyError>

Implementors§