Trait mutiny_core::storage::MutinyStorage
source · pub trait MutinyStorage: Clone + Sized + 'static {
Show 34 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>;
async fn fetch_device_lock(&self) -> Result<Option<DeviceLock>, MutinyError>;
// Provided methods
async fn set_async<T>(
&self,
key: impl AsRef<str>,
value: T
) -> Result<(), MutinyError>
where T: Serialize { ... }
fn set_data<T>(
&self,
key: impl AsRef<str>,
value: T,
version: Option<u32>
) -> Result<(), MutinyError>
where T: Serialize { ... }
async fn set_data_async<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 get_bitcoin_price_cache(
&self
) -> Result<HashMap<String, f32>, MutinyError> { ... }
fn insert_bitcoin_price_cache(
&self,
prices: HashMap<String, f32>
) -> 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> { ... }
async fn set_device_lock(&self) -> Result<(), MutinyError> { ... }
}Required Methods§
sourcefn vss_client(&self) -> Option<Arc<MutinyVssClient>>
fn vss_client(&self) -> Option<Arc<MutinyVssClient>>
Get the VSS client used for storage
sourcefn set<T>(&self, key: impl AsRef<str>, value: T) -> Result<(), MutinyError>where
T: Serialize,
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
sourcefn get<T>(&self, key: impl AsRef<str>) -> Result<Option<T>, MutinyError>where
T: for<'de> Deserialize<'de>,
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
sourcefn delete(&self, keys: &[impl AsRef<str>]) -> Result<(), MutinyError>
fn delete(&self, keys: &[impl AsRef<str>]) -> Result<(), MutinyError>
Delete a set of values from the storage
sourceasync fn start(&mut self) -> Result<(), MutinyError>
async fn start(&mut self) -> Result<(), MutinyError>
Start the storage, this will be called before any other methods
sourcefn connected(&self) -> Result<bool, MutinyError>
fn connected(&self) -> Result<bool, MutinyError>
Check if the storage is connected
sourcefn scan_keys(
&self,
prefix: &str,
suffix: Option<&str>
) -> Result<Vec<String>, MutinyError>
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.
fn change_password( &mut self, new: Option<String>, new_cipher: Option<Cipher> ) -> Result<(), MutinyError>
sourceasync fn import(json: Value) -> Result<(), MutinyError>
async fn import(json: Value) -> Result<(), MutinyError>
Override the storage with the new JSON object
sourceasync fn clear() -> Result<(), MutinyError>
async fn clear() -> Result<(), MutinyError>
Deletes all data from the storage
async fn fetch_device_lock(&self) -> Result<Option<DeviceLock>, MutinyError>
Provided Methods§
sourceasync fn set_async<T>(
&self,
key: impl AsRef<str>,
value: T
) -> Result<(), MutinyError>where
T: Serialize,
async fn set_async<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 This is an async version of set, it is not required to implement this If this is not implemented, the default implementation will just call set
sourcefn set_data<T>(
&self,
key: impl AsRef<str>,
value: T,
version: Option<u32>
) -> Result<(), MutinyError>where
T: Serialize,
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
sourceasync fn set_data_async<T>(
&self,
key: impl AsRef<str>,
value: T,
version: Option<u32>
) -> Result<(), MutinyError>where
T: Serialize,
async fn set_data_async<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
sourcefn get_data<T>(&self, key: impl AsRef<str>) -> Result<Option<T>, MutinyError>where
T: for<'de> Deserialize<'de>,
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
sourcefn scan<T>(
&self,
prefix: &str,
suffix: Option<&str>
) -> Result<HashMap<String, 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>,
Scan the storage for keys with a given prefix and suffix, and then gets their values
sourcefn insert_mnemonic(&self, mnemonic: Mnemonic) -> Result<Mnemonic, MutinyError>
fn insert_mnemonic(&self, mnemonic: Mnemonic) -> Result<Mnemonic, MutinyError>
Insert a mnemonic into the storage
sourcefn get_mnemonic(&self) -> Result<Option<Mnemonic>, MutinyError>
fn get_mnemonic(&self) -> Result<Option<Mnemonic>, MutinyError>
Get the mnemonic from the storage
fn change_password_and_rewrite_storage( &mut self, old: Option<String>, new: Option<String> ) -> Result<(), MutinyError>
sourceasync fn delete_all(&self) -> Result<(), MutinyError>
async fn delete_all(&self) -> Result<(), MutinyError>
Deletes all data from the storage and removes lock from VSS
sourcefn get_nodes(&self) -> Result<NodeStorage, MutinyError>
fn get_nodes(&self) -> Result<NodeStorage, MutinyError>
Gets the node indexes from storage
sourcefn insert_nodes(&self, nodes: NodeStorage) -> Result<(), MutinyError>
fn insert_nodes(&self, nodes: NodeStorage) -> Result<(), MutinyError>
Inserts the node indexes into storage
sourcefn get_fee_estimates(&self) -> Result<Option<HashMap<String, f64>>, MutinyError>
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
sourcefn insert_fee_estimates(
&self,
fees: HashMap<String, f64>
) -> Result<(), MutinyError>
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
sourcefn get_bitcoin_price_cache(&self) -> Result<HashMap<String, f32>, MutinyError>
fn get_bitcoin_price_cache(&self) -> Result<HashMap<String, f32>, MutinyError>
Get the current bitcoin price cache from storage
sourcefn insert_bitcoin_price_cache(
&self,
prices: HashMap<String, f32>
) -> Result<(), MutinyError>
fn insert_bitcoin_price_cache( &self, prices: HashMap<String, f32> ) -> Result<(), MutinyError>
Inserts the bitcoin price cache into storage