zcash_client_backend: Make `AccountId` an associated type of the `Account` trait.

This commit is contained in:
Kris Nuttycombe 2024-09-04 15:39:29 -06:00
parent 026f5f6de6
commit 69953ccd88
3 changed files with 19 additions and 6 deletions

View File

@ -7,6 +7,11 @@ and this library adheres to Rust's notion of
## [Unreleased]
### Changed
- The `Account` trait now uses an associated type for its `AccountId`
type instead of a type parameter. This change allows for the simplification
of some type signatures.
## [0.13.0] - 2024-08-20
`zcash_client_backend` now supports TEX (transparent-source-only) addresses as specified

View File

@ -346,9 +346,11 @@ pub enum AccountSource {
}
/// A set of capabilities that a client account must provide.
pub trait Account<AccountId: Copy> {
pub trait Account {
type AccountId: Copy;
/// Returns the unique identifier for the account.
fn id(&self) -> AccountId;
fn id(&self) -> Self::AccountId;
/// Returns whether this account is derived or imported, and the derivation parameters
/// if applicable.
@ -377,7 +379,9 @@ pub trait Account<AccountId: Copy> {
}
#[cfg(any(test, feature = "test-dependencies"))]
impl<A: Copy> Account<A> for (A, UnifiedFullViewingKey) {
impl<A: Copy> Account for (A, UnifiedFullViewingKey) {
type AccountId = A;
fn id(&self) -> A {
self.0
}
@ -398,7 +402,9 @@ impl<A: Copy> Account<A> for (A, UnifiedFullViewingKey) {
}
#[cfg(any(test, feature = "test-dependencies"))]
impl<A: Copy> Account<A> for (A, UnifiedIncomingViewingKey) {
impl<A: Copy> Account for (A, UnifiedIncomingViewingKey) {
type AccountId = A;
fn id(&self) -> A {
self.0
}
@ -804,7 +810,7 @@ pub trait WalletRead {
type AccountId: Copy + Debug + Eq + Hash;
/// The concrete account type used by this wallet backend.
type Account: Account<Self::AccountId>;
type Account: Account<AccountId = Self::AccountId>;
/// Returns a vector with the IDs of all accounts known to this wallet.
fn get_account_ids(&self) -> Result<Vec<Self::AccountId>, Self::Error>;

View File

@ -220,7 +220,9 @@ impl Account {
}
}
impl zcash_client_backend::data_api::Account<AccountId> for Account {
impl zcash_client_backend::data_api::Account for Account {
type AccountId = AccountId;
fn id(&self) -> AccountId {
self.account_id
}