pub trait AsyncWalletPersister {
type Error;
// Required methods
fn initialize<'a>(
persister: &'a mut Self,
) -> Pin<Box<dyn Future<Output = Result<ChangeSet, Self::Error>> + Send + 'a>>
where Self: 'a;
fn persist<'a>(
persister: &'a mut Self,
changeset: &'a ChangeSet,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'a>>
where Self: 'a;
}
Expand description
Async trait that persists PersistedWallet
.
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!). 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.
Required Associated Types§
Required Methods§
Sourcefn initialize<'a>(
persister: &'a mut Self,
) -> Pin<Box<dyn Future<Output = Result<ChangeSet, Self::Error>> + Send + 'a>>where
Self: 'a,
fn initialize<'a>(
persister: &'a mut Self,
) -> Pin<Box<dyn Future<Output = Result<ChangeSet, Self::Error>> + Send + 'a>>where
Self: 'a,
Initialize the persister
and load all data.
This is called by PersistedWallet::create_async
and PersistedWallet::load_async
to
ensure the AsyncWalletPersister
is initialized and returns all data in the persister
.
§Implementation Details
The database schema of the persister
(if any), should be initialized and migrated here.
The implementation must return all data currently stored in the persister
. If there is no
data, return an empty changeset (using ChangeSet::default()
).
Error should only occur on database failure. Multiple calls to initialize
should not
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).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.