Skip to main content

LAError

Enum LAError 

Source
#[non_exhaustive]
pub enum LAError {
Show 19 variants InvalidArgument(String), TimedOut(String), BridgeFailed(String), AuthenticationFailed(String), UserCancel(String), UserFallback(String), SystemCancel(String), PasscodeNotSet(String), BiometryNotAvailable(String), BiometryNotEnrolled(String), BiometryLockout(String), AppCancel(String), InvalidContext(String), NotInteractive(String), CompanionNotAvailable(String), BiometryNotPaired(String), BiometryDisconnected(String), InvalidDimensions(String), Other { code: i32, message: String, },
}
Expand description

Top-level error type returned by this crate.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

InvalidArgument(String)

Invalid input crossed the FFI boundary.

§

TimedOut(String)

The framework callback did not complete before the bridge timeout elapsed.

§

BridgeFailed(String)

The Swift bridge failed before reaching the framework call.

§

AuthenticationFailed(String)

Authentication was not successful because valid credentials were not provided.

§

UserCancel(String)

Authentication was cancelled by the user.

§

UserFallback(String)

Authentication was cancelled because the fallback button was tapped.

§

SystemCancel(String)

Authentication was cancelled by the system.

§

PasscodeNotSet(String)

Authentication cannot start because no device passcode is configured.

§

BiometryNotAvailable(String)

Authentication cannot start because biometry is unavailable.

§

BiometryNotEnrolled(String)

Authentication cannot start because no biometric identities are enrolled.

§

BiometryLockout(String)

Authentication cannot start because biometry is locked.

§

AppCancel(String)

Authentication was cancelled by the application.

§

InvalidContext(String)

The LAContext has already been invalidated.

§

NotInteractive(String)

Authentication would require UI while interaction is disallowed.

§

CompanionNotAvailable(String)

Authentication cannot start because no companion device is nearby.

§

BiometryNotPaired(String)

Authentication cannot start because the paired biometric accessory is unavailable.

§

BiometryDisconnected(String)

Authentication cannot start because the paired biometric accessory is disconnected.

§

InvalidDimensions(String)

Authentication cannot start because an embedded UI size is invalid.

§

Other

Catch-all for unmapped framework or bridge status codes.

Fields

§code: i32
§message: String

Implementations§

Source§

impl LAError

Source

pub const fn code(&self) -> i32

Numeric bridge, LAError, or OSStatus code reported by the bridge.

Source

pub fn message(&self) -> &str

Human-readable description returned by the Swift bridge.

Source

pub const fn domain() -> &'static str

LocalAuthentication’s NSError domain string.

Source

pub fn from_code_message(code: i32, message: impl Into<String>) -> Self

Build an error value from a numeric code and message.

Examples found in repository?
examples/03_error_codes.rs (line 6)
4fn main() {
5    let errors = [
6        LAError::from_code_message(ffi::la_error::BIOMETRY_LOCKOUT, "biometry locked"),
7        LAError::from_code_message(ffi::la_error::COMPANION_NOT_AVAILABLE, "companion missing"),
8        LAError::from_code_message(ffi::status::BRIDGE_FAILED, "bridge failed"),
9    ];
10
11    println!("domain: {LA_ERROR_DOMAIN}");
12    for error in errors {
13        println!("{error:?} => {error}");
14    }
15    println!("✅ error mapping OK");
16}

Trait Implementations§

Source§

impl Clone for LAError

Source§

fn clone(&self) -> LAError

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 LAError

Source§

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

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

impl Display for LAError

Source§

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

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

impl Error for LAError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for LAError

Source§

fn eq(&self, other: &LAError) -> 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 LAError

Source§

impl StructuralPartialEq for LAError

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.