pub trait Derive {
type Account: AsRef<DerivedAccount>;
type Error: Debug + Display + From<DeriveError>;
// Required methods
fn derive(&self, index: u32) -> Result<Self::Account, Self::Error>;
fn derive_path(&self, path: &str) -> Result<Self::Account, Self::Error>;
}Expand description
Unified derivation trait implemented by every chain deriver.
Each chain implements this trait on its Deriver type and declares the
account newtype it returns via the associated Account
type. The AsRef<DerivedAccount> bound keeps the unified read view
available to generic callers, without erasing chain-specific metadata
(BTC WIF, Solana keypair, Nostr nsec, …).
Batch derivation is provided by the blanket DeriveExt trait.
§Example
use kobe_primitives::{Derive, DerivedAccount};
fn first_address<D: Derive>(d: &D) -> String {
// `as_ref` yields the unified view regardless of the chain newtype.
let account = d.derive(0).unwrap();
let view: &DerivedAccount = account.as_ref();
view.address().to_owned()
}Required Associated Types§
Sourcetype Account: AsRef<DerivedAccount>
type Account: AsRef<DerivedAccount>
The (possibly newtype) account returned by this deriver.
Chains without chain-specific metadata set Account = DerivedAccount
directly; chains with extra fields (BTC, SVM, Nostr) return their
own <Chain>Account wrapper.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".