Skip to main content

Prompt

Struct Prompt 

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

What a person is asked to do, and how the dialog may let them do it.

Implementations§

Source§

impl Prompt

Source

pub fn new(reason: impl Into<String>) -> Self

A prompt that explains, in the person’s language, why the app asks. The text is shown in the system dialog: as the reason under the Face ID glyph on Apple platforms, the title of the Android sheet, the message of the Windows Hello window, the title of the HarmonyOS dialog. An empty reason is rejected with BiometricError::InvalidPrompt, because Apple aborts on one and the others show a blank dialog. Localize it with res::str.

Source

pub fn fallback_title(self, title: impl Into<String>) -> Self

The label of the button that leads away from the biometric. With the device credential allowed it is the “use passcode” button (Apple), with it refused it is the negative button that dismisses the dialog (Android), and the platforms with no such button ignore it.

Source

pub fn device_credential(self, allowed: bool) -> Self

Whether the dialog offers the device credential (passcode, PIN, pattern, password) as a way to pass. true by default, and what most apps want: a person whose finger is wet can still get in. false asks for a biometric only; a device with none enrolled then fails with BiometricError::NotEnrolled. Windows Hello decides this itself and ignores the flag.

Source

pub fn challenge(self, challenge: impl Into<Vec<u8>>) -> Self

Bytes the platform binds the result to. HarmonyOS issues an authentication token for the challenge it is given (32 bytes at most) and a key bound to the same challenge accepts that token once; day-part-keychain passes the challenge its keystore produced. Every other platform ignores the challenge and returns an empty token.

Source

pub fn reason(&self) -> &str

The reason shown in the dialog.

Source

pub fn fallback_title_text(&self) -> Option<&str>

The fallback button’s label, when one was given.

Source

pub fn allows_device_credential(&self) -> bool

Whether the device credential may pass the prompt.

Source

pub fn challenge_bytes(&self) -> &[u8] ⓘ

The challenge bytes, empty unless Prompt::challenge set them.

Trait Implementations§

Source§

impl Clone for Prompt

Source§

fn clone(&self) -> Prompt

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 Prompt

Source§

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

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

impl Eq for Prompt

Source§

impl PartialEq for Prompt

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Prompt

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.
Day API ↩ Guides· daybrite.dev