pub trait MultiDeviceProvider {
// Required methods
fn register_device(
&mut self,
env: &Env,
key_id: BytesN<32>,
device_name: Symbol,
) -> Result<DeviceKey, AccountError>;
fn revoke_device(
&mut self,
env: &Env,
key_id: &BytesN<32>,
) -> Result<(), AccountError>;
fn list_devices(&self, env: &Env) -> Vec<DeviceKey>;
fn active_device_count(&self, env: &Env) -> usize;
fn update_last_used(
&mut self,
env: &Env,
key_id: &BytesN<32>,
) -> Result<(), AccountError>;
fn set_policy(&mut self, env: &Env, policy: DevicePolicy);
fn policy(&self, env: &Env) -> DevicePolicy;
fn cleanup_inactive(&mut self, env: &Env) -> u32;
}Expand description
Trait for account types that support multi-device key management.
Required Methods§
Sourcefn register_device(
&mut self,
env: &Env,
key_id: BytesN<32>,
device_name: Symbol,
) -> Result<DeviceKey, AccountError>
fn register_device( &mut self, env: &Env, key_id: BytesN<32>, device_name: Symbol, ) -> Result<DeviceKey, AccountError>
Register a new device key.
Sourcefn revoke_device(
&mut self,
env: &Env,
key_id: &BytesN<32>,
) -> Result<(), AccountError>
fn revoke_device( &mut self, env: &Env, key_id: &BytesN<32>, ) -> Result<(), AccountError>
Revoke a device key by its ID.
Sourcefn list_devices(&self, env: &Env) -> Vec<DeviceKey>
fn list_devices(&self, env: &Env) -> Vec<DeviceKey>
List all registered device keys (active and inactive).
Sourcefn active_device_count(&self, env: &Env) -> usize
fn active_device_count(&self, env: &Env) -> usize
Returns the number of active devices.
Sourcefn update_last_used(
&mut self,
env: &Env,
key_id: &BytesN<32>,
) -> Result<(), AccountError>
fn update_last_used( &mut self, env: &Env, key_id: &BytesN<32>, ) -> Result<(), AccountError>
Update the last_used timestamp for a device.
Sourcefn set_policy(&mut self, env: &Env, policy: DevicePolicy)
fn set_policy(&mut self, env: &Env, policy: DevicePolicy)
Set the device management policy.
Sourcefn policy(&self, env: &Env) -> DevicePolicy
fn policy(&self, env: &Env) -> DevicePolicy
Get the current device policy.
Sourcefn cleanup_inactive(&mut self, env: &Env) -> u32
fn cleanup_inactive(&mut self, env: &Env) -> u32
Revoke devices that have been inactive beyond the policy’s auto_revoke_after. Returns the number of devices revoked.