@@ -36,7 +36,10 @@ pub trait WalletPersister {
36
36
/// data, return an empty changeset (using [`ChangeSet::default()`]).
37
37
///
38
38
/// Error should only occur on database failure. Multiple calls to `initialize` should not
39
- /// error. Calling [`persist`] before calling `initialize` should not error either.
39
+ /// error. Calling `initialize` inbetween calls to `persist` should not error.
40
+ ///
41
+ /// Calling [`persist`] before the `persister` is `initialize`d may error. However, some
42
+ /// persister implementations may NOT require initialization at all (and not error).
40
43
///
41
44
/// [`persist`]: WalletPersister::persist
42
45
fn initialize ( persister : & mut Self ) -> Result < ChangeSet , Self :: Error > ;
@@ -56,7 +59,7 @@ type FutureResult<'a, T, E> = Pin<Box<dyn Future<Output = Result<T, E>> + Send +
56
59
/// For a blocking version, use [`WalletPersister`].
57
60
///
58
61
/// Associated functions of this trait should not be called directly, and the trait is designed so
59
- /// that associated functions are hard to find (since they are not methods!). [`WalletPersister `] is
62
+ /// that associated functions are hard to find (since they are not methods!). [`AsyncWalletPersister `] is
60
63
/// used by [`PersistedWallet`] (a light wrapper around [`Wallet`]) which enforces some level of
61
64
/// safety. Refer to [`PersistedWallet`] for more about the safety checks.
62
65
pub trait AsyncWalletPersister {
@@ -66,7 +69,7 @@ pub trait AsyncWalletPersister {
66
69
/// Initialize the `persister` and load all data.
67
70
///
68
71
/// This is called by [`PersistedWallet::create_async`] and [`PersistedWallet::load_async`] to
69
- /// ensure the [`WalletPersister `] is initialized and returns all data in the `persister`.
72
+ /// ensure the [`AsyncWalletPersister `] is initialized and returns all data in the `persister`.
70
73
///
71
74
/// # Implementation Details
72
75
///
@@ -76,7 +79,10 @@ pub trait AsyncWalletPersister {
76
79
/// data, return an empty changeset (using [`ChangeSet::default()`]).
77
80
///
78
81
/// Error should only occur on database failure. Multiple calls to `initialize` should not
79
- /// error. Calling [`persist`] before calling `initialize` should not error either.
82
+ /// error. Calling `initialize` inbetween calls to `persist` should not error.
83
+ ///
84
+ /// Calling [`persist`] before the `persister` is `initialize`d may error. However, some
85
+ /// persister implementations may NOT require initialization at all (and not error).
80
86
///
81
87
/// [`persist`]: AsyncWalletPersister::persist
82
88
fn initialize < ' a > ( persister : & ' a mut Self ) -> FutureResult < ' a , ChangeSet , Self :: Error >
@@ -171,6 +177,8 @@ impl<P: WalletPersister> PersistedWallet<P> {
171
177
172
178
/// Persist staged changes of wallet into `persister`.
173
179
///
180
+ /// Returns whether any new changes were persisted.
181
+ ///
174
182
/// If the `persister` errors, the staged changes will not be cleared.
175
183
pub fn persist ( & mut self , persister : & mut P ) -> Result < bool , P :: Error > {
176
184
match self . inner . staged_mut ( ) {
@@ -186,7 +194,7 @@ impl<P: WalletPersister> PersistedWallet<P> {
186
194
187
195
/// Methods when `P` is an [`AsyncWalletPersister`].
188
196
impl < P : AsyncWalletPersister > PersistedWallet < P > {
189
- /// Create a new [`PersistedWallet`] witht the given async `persister` and `params`.
197
+ /// Create a new [`PersistedWallet`] with the given async `persister` and `params`.
190
198
pub async fn create_async (
191
199
persister : & mut P ,
192
200
params : CreateParams ,
@@ -230,6 +238,8 @@ impl<P: AsyncWalletPersister> PersistedWallet<P> {
230
238
231
239
/// Persist staged changes of wallet into an async `persister`.
232
240
///
241
+ /// Returns whether any new changes were persisted.
242
+ ///
233
243
/// If the `persister` errors, the staged changes will not be cleared.
234
244
pub async fn persist_async < ' a > ( & ' a mut self , persister : & mut P ) -> Result < bool , P :: Error > {
235
245
match self . inner . staged_mut ( ) {
0 commit comments