pub struct DeviceManager { /* private fields */ }Expand description
Persistent implementation of multi-device management.
Device keys and policy are stored in Soroban persistent storage
via DeviceStorage, surviving across contract invocations.
Implementations§
Source§impl DeviceManager
impl DeviceManager
Sourcepub fn new(address: Address, policy: DevicePolicy, env: &Env) -> Self
pub fn new(address: Address, policy: DevicePolicy, env: &Env) -> Self
Create a new device manager with the given policy, persisting it.
Sourcepub fn load(address: Address) -> Self
pub fn load(address: Address) -> Self
Load an existing device manager (policy must already be stored).
Sourcepub fn with_defaults(address: Address, env: &Env) -> Self
pub fn with_defaults(address: Address, env: &Env) -> Self
Create a device manager with a default policy.
Trait Implementations§
Source§impl MultiDeviceProvider for DeviceManager
impl MultiDeviceProvider for DeviceManager
Source§fn 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.
Source§fn 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.
Source§fn list_devices(&self, env: &Env) -> Vec<DeviceKey>
fn list_devices(&self, env: &Env) -> Vec<DeviceKey>
List all registered device keys (active and inactive).
Source§fn active_device_count(&self, env: &Env) -> usize
fn active_device_count(&self, env: &Env) -> usize
Returns the number of active devices.
Source§fn 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.
Source§fn set_policy(&mut self, env: &Env, policy: DevicePolicy)
fn set_policy(&mut self, env: &Env, policy: DevicePolicy)
Set the device management policy.
Source§fn policy(&self, env: &Env) -> DevicePolicy
fn policy(&self, env: &Env) -> DevicePolicy
Get the current device policy.
Source§fn 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.
Auto Trait Implementations§
impl Freeze for DeviceManager
impl !RefUnwindSafe for DeviceManager
impl !Send for DeviceManager
impl !Sync for DeviceManager
impl Unpin for DeviceManager
impl UnsafeUnpin for DeviceManager
impl !UnwindSafe for DeviceManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W), ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
Source§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for C
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X), ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more