Struct mutiny_core::storage::MemoryStorage
source · pub struct MemoryStorage {
pub password: Option<String>,
pub cipher: Option<Cipher>,
pub memory: Arc<RwLock<HashMap<String, Value>>>,
pub vss_client: Option<Arc<MutinyVssClient>>,
}Fields§
§password: Option<String>§cipher: Option<Cipher>§memory: Arc<RwLock<HashMap<String, Value>>>§vss_client: Option<Arc<MutinyVssClient>>Implementations§
source§impl MemoryStorage
impl MemoryStorage
pub fn new( password: Option<String>, cipher: Option<Cipher>, vss_client: Option<Arc<MutinyVssClient>> ) -> Self
pub async fn load_from_vss(&self) -> Result<(), MutinyError>
Trait Implementations§
source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
source§fn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Default for MemoryStorage
impl Default for MemoryStorage
source§impl MutinyStorage for MemoryStorage
impl MutinyStorage for MemoryStorage
source§fn vss_client(&self) -> Option<Arc<MutinyVssClient>>
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,
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>,
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>
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>
async fn start(&mut self) -> Result<(), MutinyError>
Start the storage, this will be called before any other methods
source§fn 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>
source§async fn import(_json: Value) -> Result<(), MutinyError>
async fn import(_json: Value) -> Result<(), MutinyError>
Override the storage with the new JSON object
async fn fetch_device_lock(&self) -> Result<Option<DeviceLock>, MutinyError>
source§async 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
source§fn 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
source§async 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
source§fn 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
source§fn 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
source§fn insert_mnemonic(&self, mnemonic: Mnemonic) -> Result<Mnemonic, MutinyError>
fn insert_mnemonic(&self, mnemonic: Mnemonic) -> Result<Mnemonic, MutinyError>
Insert a mnemonic into the storage
source§fn 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>
source§async fn delete_all(&self) -> Result<(), MutinyError>
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>
fn get_nodes(&self) -> Result<NodeStorage, MutinyError>
Gets the node indexes from storage
source§fn insert_nodes(&self, nodes: NodeStorage) -> Result<(), MutinyError>
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>
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>
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 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
source§fn 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
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>
Auto Trait Implementations§
impl !RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl !UnwindSafe for MemoryStorage
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<S> LabelStorage for Swhere
S: MutinyStorage,
impl<S> LabelStorage for Swhere S: MutinyStorage,
source§fn create_new_contact(&self, contact: Contact) -> Result<String, MutinyError>
fn create_new_contact(&self, contact: Contact) -> Result<String, MutinyError>
Create a new contact and return the identifying label
source§fn get_address_labels(
&self
) -> Result<HashMap<String, Vec<String>>, MutinyError>
fn get_address_labels( &self ) -> Result<HashMap<String, Vec<String>>, MutinyError>
Get a map of addresses to labels. This can be used to get all the labels for an address
source§fn get_invoice_labels(
&self
) -> Result<HashMap<Bolt11Invoice, Vec<String>>, MutinyError>
fn get_invoice_labels( &self ) -> Result<HashMap<Bolt11Invoice, Vec<String>>, MutinyError>
Get a map of invoices to labels. This can be used to get all the labels for an invoice
source§fn get_labels(&self) -> Result<HashMap<String, LabelItem>, MutinyError>
fn get_labels(&self) -> Result<HashMap<String, LabelItem>, MutinyError>
Get all the existing labels
source§fn get_label(
&self,
label: impl AsRef<str>
) -> Result<Option<LabelItem>, MutinyError>
fn get_label( &self, label: impl AsRef<str> ) -> Result<Option<LabelItem>, MutinyError>
Get information about a label
source§fn set_address_labels(
&self,
address: Address,
labels: Vec<String>
) -> Result<(), MutinyError>
fn set_address_labels( &self, address: Address, labels: Vec<String> ) -> Result<(), MutinyError>
Set the labels for an address, replacing any existing labels
If you do not want to replace any existing labels, use
get_address_labels to get the existing labels,
add the new labels, and then use set_address_labels to set the new labelssource§fn set_invoice_labels(
&self,
invoice: Bolt11Invoice,
labels: Vec<String>
) -> Result<(), MutinyError>
fn set_invoice_labels( &self, invoice: Bolt11Invoice, labels: Vec<String> ) -> Result<(), MutinyError>
Set the labels for an invoice, replacing any existing labels
If you do not want to replace any existing labels, use
get_invoice_labels to get the existing labels,
add the new labels, and then use set_invoice_labels to set the new labelssource§fn get_contacts(&self) -> Result<HashMap<String, Contact>, MutinyError>
fn get_contacts(&self) -> Result<HashMap<String, Contact>, MutinyError>
Get all the existing contacts
source§fn get_contact(
&self,
label: impl AsRef<str>
) -> Result<Option<Contact>, MutinyError>
fn get_contact( &self, label: impl AsRef<str> ) -> Result<Option<Contact>, MutinyError>
Get a contact by label, the label should be a uuid
source§fn create_contact_from_label(
&self,
label: impl AsRef<str>,
contact: Contact
) -> Result<String, MutinyError>
fn create_contact_from_label( &self, label: impl AsRef<str>, contact: Contact ) -> Result<String, MutinyError>
Create a new contact from an existing label and returns the new identifying label
source§fn archive_contact(&self, id: impl AsRef<str>) -> Result<(), MutinyError>
fn archive_contact(&self, id: impl AsRef<str>) -> Result<(), MutinyError>
Marks a contact as archived
source§fn edit_contact(
&self,
id: impl AsRef<str>,
contact: Contact
) -> Result<(), MutinyError>
fn edit_contact( &self, id: impl AsRef<str>, contact: Contact ) -> Result<(), MutinyError>
Edits an existing contact and replaces the existing contact
source§fn get_tag_items(&self) -> Result<Vec<TagItem>, MutinyError>
fn get_tag_items(&self) -> Result<Vec<TagItem>, MutinyError>
Gets all the existing tags (labels and contacts)