pub trait Keyring: Send + Sync {
// Required methods
fn keyring_type(&self) -> &str;
fn serialize(&self) -> Result<Vec<u8>, KeyringError>;
fn deserialize(data: &[u8]) -> Result<Self, KeyringError>
where Self: Sized;
fn add_accounts(
&mut self,
private_keys: &[String],
) -> Result<Vec<KeyringAccount>, KeyringError>;
fn get_accounts(&self) -> Vec<KeyringAccount>;
fn export_account(&self, address: &str) -> Result<String, KeyringError>;
fn remove_account(&mut self, address: &str) -> Result<(), KeyringError>;
fn sign_hash(
&self,
address: &str,
hash: &[u8; 32],
) -> Result<[u8; 65], KeyringError>;
}Required Methods§
Sourcefn keyring_type(&self) -> &str
fn keyring_type(&self) -> &str
Keyring type identifier (e.g., “simple”, “hd”)
Sourcefn serialize(&self) -> Result<Vec<u8>, KeyringError>
fn serialize(&self) -> Result<Vec<u8>, KeyringError>
Serialize keyring state (for encrypted storage)
Sourcefn deserialize(data: &[u8]) -> Result<Self, KeyringError>where
Self: Sized,
fn deserialize(data: &[u8]) -> Result<Self, KeyringError>where
Self: Sized,
Deserialize keyring state
Sourcefn add_accounts(
&mut self,
private_keys: &[String],
) -> Result<Vec<KeyringAccount>, KeyringError>
fn add_accounts( &mut self, private_keys: &[String], ) -> Result<Vec<KeyringAccount>, KeyringError>
Add accounts (for SimpleKeyring: import private keys)
Sourcefn get_accounts(&self) -> Vec<KeyringAccount>
fn get_accounts(&self) -> Vec<KeyringAccount>
Get all accounts managed by this keyring
Sourcefn export_account(&self, address: &str) -> Result<String, KeyringError>
fn export_account(&self, address: &str) -> Result<String, KeyringError>
Export a private key for a given address
Sourcefn remove_account(&mut self, address: &str) -> Result<(), KeyringError>
fn remove_account(&mut self, address: &str) -> Result<(), KeyringError>
Remove an account by address