self
}
- /// Create [`PersistedWallet`] with the given `Db`.
+ /// Create [`PersistedWallet`] with the given [`WalletPersister`].
pub fn create_wallet<P>(
self,
persister: &mut P,
PersistedWallet::create(persister, self)
}
- /// Create [`PersistedWallet`] with the given async `Db`.
+ /// Create [`PersistedWallet`] with the given [`AsyncWalletPersister`].
pub async fn create_wallet_async<P>(
self,
persister: &mut P,
self
}
- /// Load [`PersistedWallet`] with the given `persister`.
+ /// Load [`PersistedWallet`] with the given [`WalletPersister`].
pub fn load_wallet<P>(
self,
persister: &mut P,
PersistedWallet::load(persister, self)
}
- /// Load [`PersistedWallet`] with the given async `persister`.
+ /// Load [`PersistedWallet`] with the given [`AsyncWalletPersister`].
pub async fn load_wallet_async<P>(
self,
persister: &mut P,
/// data, return an empty changeset (using [`ChangeSet::default()`]).
///
/// Error should only occur on database failure. Multiple calls to `initialize` should not
- /// error. Calling [`persist`] before calling `initialize` should not error either.
+ /// error. Calling `initialize` inbetween calls to `persist` should not error.
+ ///
+ /// Calling [`persist`] before the `persister` is `initialize`d may error. However, some
+ /// persister implementations may NOT require initialization at all (and not error).
///
/// [`persist`]: WalletPersister::persist
fn initialize(persister: &mut Self) -> Result<ChangeSet, Self::Error>;
/// For a blocking version, use [`WalletPersister`].
///
/// Associated functions of this trait should not be called directly, and the trait is designed so
-/// that associated functions are hard to find (since they are not methods!). [`WalletPersister`] is
+/// that associated functions are hard to find (since they are not methods!). [`AsyncWalletPersister`] is
/// used by [`PersistedWallet`] (a light wrapper around [`Wallet`]) which enforces some level of
/// safety. Refer to [`PersistedWallet`] for more about the safety checks.
pub trait AsyncWalletPersister {
/// Initialize the `persister` and load all data.
///
/// This is called by [`PersistedWallet::create_async`] and [`PersistedWallet::load_async`] to
- /// ensure the [`WalletPersister`] is initialized and returns all data in the `persister`.
+ /// ensure the [`AsyncWalletPersister`] is initialized and returns all data in the `persister`.
///
/// # Implementation Details
///
/// data, return an empty changeset (using [`ChangeSet::default()`]).
///
/// Error should only occur on database failure. Multiple calls to `initialize` should not
- /// error. Calling [`persist`] before calling `initialize` should not error either.
+ /// error. Calling `initialize` inbetween calls to `persist` should not error.
+ ///
+ /// Calling [`persist`] before the `persister` is `initialize`d may error. However, some
+ /// persister implementations may NOT require initialization at all (and not error).
///
/// [`persist`]: AsyncWalletPersister::persist
fn initialize<'a>(persister: &'a mut Self) -> FutureResult<'a, ChangeSet, Self::Error>
/// Persist staged changes of wallet into `persister`.
///
+ /// Returns whether any new changes were persisted.
+ ///
/// If the `persister` errors, the staged changes will not be cleared.
pub fn persist(&mut self, persister: &mut P) -> Result<bool, P::Error> {
match self.inner.staged_mut() {
/// Methods when `P` is an [`AsyncWalletPersister`].
impl<P: AsyncWalletPersister> PersistedWallet<P> {
- /// Create a new [`PersistedWallet`] witht the given async `persister` and `params`.
+ /// Create a new [`PersistedWallet`] with the given async `persister` and `params`.
pub async fn create_async(
persister: &mut P,
params: CreateParams,
/// Persist staged changes of wallet into an async `persister`.
///
+ /// Returns whether any new changes were persisted.
+ ///
/// If the `persister` errors, the staged changes will not be cleared.
pub async fn persist_async<'a>(&'a mut self, persister: &mut P) -> Result<bool, P::Error> {
match self.inner.staged_mut() {