Storage

Trait Storage 

Source
pub trait Storage: Send + Sync {
Show 23 methods // Required methods fn delete_cached_item<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_cached_item<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_cached_item<'life0, 'async_trait>( &'life0 self, key: String, value: String, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn list_payments<'life0, 'async_trait>( &'life0 self, request: StorageListPaymentsRequest, ) -> Pin<Box<dyn Future<Output = Result<Vec<Payment>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn insert_payment<'life0, 'async_trait>( &'life0 self, payment: Payment, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn insert_payment_metadata<'life0, 'async_trait>( &'life0 self, payment_id: String, metadata: PaymentMetadata, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_payment_by_id<'life0, 'async_trait>( &'life0 self, id: String, ) -> Pin<Box<dyn Future<Output = Result<Payment, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_payment_by_invoice<'life0, 'async_trait>( &'life0 self, invoice: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Payment>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_payments_by_parent_ids<'life0, 'async_trait>( &'life0 self, parent_payment_ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<Payment>>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, amount_sats: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn delete_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn list_deposits<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DepositInfo>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, payload: UpdateDepositPayload, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn set_lnurl_metadata<'life0, 'async_trait>( &'life0 self, metadata: Vec<SetLnurlMetadataItem>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn add_outgoing_change<'life0, 'async_trait>( &'life0 self, record: UnversionedRecordChange, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn complete_outgoing_sync<'life0, 'async_trait>( &'life0 self, record: Record, local_revision: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_pending_outgoing_changes<'life0, 'async_trait>( &'life0 self, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<OutgoingChange>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_last_revision<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn insert_incoming_records<'life0, 'async_trait>( &'life0 self, records: Vec<Record>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn delete_incoming_record<'life0, 'async_trait>( &'life0 self, record: Record, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_incoming_records<'life0, 'async_trait>( &'life0 self, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<IncomingChange>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn get_latest_outgoing_change<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<OutgoingChange>, StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn update_record_from_incoming<'life0, 'async_trait>( &'life0 self, record: Record, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

Trait for persistent storage

Required Methods§

Source

fn delete_cached_item<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_cached_item<'life0, 'async_trait>( &'life0 self, key: String, ) -> Pin<Box<dyn Future<Output = Result<Option<String>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn set_cached_item<'life0, 'async_trait>( &'life0 self, key: String, value: String, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn list_payments<'life0, 'async_trait>( &'life0 self, request: StorageListPaymentsRequest, ) -> Pin<Box<dyn Future<Output = Result<Vec<Payment>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists payments with optional filters and pagination

§Arguments
  • list_payments_request - The request to list payments
§Returns

A vector of payments or a StorageError

Source

fn insert_payment<'life0, 'async_trait>( &'life0 self, payment: Payment, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Inserts a payment into storage

§Arguments
  • payment - The payment to insert
§Returns

Success or a StorageError

Source

fn insert_payment_metadata<'life0, 'async_trait>( &'life0 self, payment_id: String, metadata: PaymentMetadata, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Inserts payment metadata into storage

§Arguments
  • payment_id - The ID of the payment
  • metadata - The metadata to insert
§Returns

Success or a StorageError

Source

fn get_payment_by_id<'life0, 'async_trait>( &'life0 self, id: String, ) -> Pin<Box<dyn Future<Output = Result<Payment, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets a payment by its ID

§Arguments
  • id - The ID of the payment to retrieve
§Returns

The payment if found or None if not found

Source

fn get_payment_by_invoice<'life0, 'async_trait>( &'life0 self, invoice: String, ) -> Pin<Box<dyn Future<Output = Result<Option<Payment>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets a payment by its invoice

§Arguments
  • invoice - The invoice of the payment to retrieve
§Returns

The payment if found or None if not found

Source

fn get_payments_by_parent_ids<'life0, 'async_trait>( &'life0 self, parent_payment_ids: Vec<String>, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Vec<Payment>>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Gets payments that have any of the specified parent payment IDs. Used to load related payments for a set of parent payments.

§Arguments
  • parent_payment_ids - The IDs of the parent payments
§Returns

A map of parent_payment_id -> Vec or a StorageError

Source

fn add_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, amount_sats: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Add a deposit to storage

§Arguments
  • txid - The transaction ID of the deposit
  • vout - The output index of the deposit
  • amount_sats - The amount of the deposit in sats
§Returns

Success or a StorageError

Source

fn delete_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Removes an unclaimed deposit from storage

§Arguments
  • txid - The transaction ID of the deposit
  • vout - The output index of the deposit
§Returns

Success or a StorageError

Source

fn list_deposits<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<DepositInfo>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Lists all unclaimed deposits from storage

§Returns

A vector of DepositInfo or a StorageError

Source

fn update_deposit<'life0, 'async_trait>( &'life0 self, txid: String, vout: u32, payload: UpdateDepositPayload, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Updates or inserts unclaimed deposit details

§Arguments
  • txid - The transaction ID of the deposit
  • vout - The output index of the deposit
  • payload - The payload for the update
§Returns

Success or a StorageError

Source

fn set_lnurl_metadata<'life0, 'async_trait>( &'life0 self, metadata: Vec<SetLnurlMetadataItem>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn add_outgoing_change<'life0, 'async_trait>( &'life0 self, record: UnversionedRecordChange, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn complete_outgoing_sync<'life0, 'async_trait>( &'life0 self, record: Record, local_revision: u64, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_pending_outgoing_changes<'life0, 'async_trait>( &'life0 self, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<OutgoingChange>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source

fn get_last_revision<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u64, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the last committed sync revision.

The sync_revision table tracks the highest revision that has been committed (i.e. acknowledged by the server or received from it). It does NOT include pending outgoing queue ids. This value is used by the sync protocol to request changes from the server.

Source

fn insert_incoming_records<'life0, 'async_trait>( &'life0 self, records: Vec<Record>, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert incoming records from remote sync

Source

fn delete_incoming_record<'life0, 'async_trait>( &'life0 self, record: Record, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete an incoming record after it has been processed

Source

fn get_incoming_records<'life0, 'async_trait>( &'life0 self, limit: u32, ) -> Pin<Box<dyn Future<Output = Result<Vec<IncomingChange>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get incoming records that need to be processed, up to the specified limit

Source

fn get_latest_outgoing_change<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Option<OutgoingChange>, StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the latest outgoing record if any exists

Source

fn update_record_from_incoming<'life0, 'async_trait>( &'life0 self, record: Record, ) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Update the sync state record from an incoming record

Implementors§