Skip to main content

LADomainState

Struct LADomainState 

Source
pub struct LADomainState { /* private fields */ }
Expand description

A snapshot of LAContext.domainState.

Implementations§

Source§

impl LADomainState

Source

pub fn state_hash(&self) -> Option<&[u8]>

Examples found in repository?
examples/01_smoke.rs (line 29)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4    let context = LAContext::new()?;
5    context.set_interaction_not_allowed(true)?;
6    context.set_localized_fallback_title(Some("Use Password"))?;
7    context.set_localized_cancel_title(Some("Cancel"))?;
8    context.set_localized_reason("inspect the device owner's authentication state")?;
9    context.set_touch_id_authentication_allowable_reuse_duration(30.0)?;
10
11    let credential = LACredential::application_password(b"secret".to_vec());
12    assert!(context.set_credential(&credential)?);
13    assert!(context.is_credential_set(LACredentialType::ApplicationPassword)?);
14    assert!(context.clear_credential(LACredentialType::ApplicationPassword)?);
15
16    let preflight =
17        match context.can_evaluate_policy(LAPolicy::DeviceOwnerAuthenticationWithBiometrics) {
18            Ok(true) => "biometry available".to_owned(),
19            Ok(false) => "biometry unavailable without a framework error".to_owned(),
20            Err(error) => format!("biometry unavailable: {error}"),
21        };
22    let domain_state = context.domain_state()?;
23
24    println!("preflight: {preflight}");
25    println!("localized reason: {}", context.localized_reason()?);
26    println!("biometry type: {:?}", context.biometry_type()?);
27    println!(
28        "domain state hash bytes: {}",
29        domain_state.state_hash().map_or(0, <[u8]>::len)
30    );
31    println!(
32        "reuse max seconds: {}",
33        LAContext::touch_id_authentication_maximum_allowable_reuse_duration()
34    );
35    println!("✅ localauth context + credentials OK");
36    Ok(())
37}
Source

pub const fn biometry(&self) -> &LADomainStateBiometry

Source

pub const fn companion(&self) -> Option<&LADomainStateCompanion>

Trait Implementations§

Source§

impl Clone for LADomainState

Source§

fn clone(&self) -> LADomainState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LADomainState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LADomainState

Source§

fn eq(&self, other: &LADomainState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LADomainState

Source§

impl StructuralPartialEq for LADomainState

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.