Skip to main content

Hints

Struct Hints 

Source
pub struct Hints(/* private fields */);
Expand description

Unique sequence of PublicKeyCredentialHint.

Implementations§

Source§

impl Hints

Source

pub const EMPTY: Self

Empty sequence of PublicKeyCredentialHints.

Source

pub const fn add(self, hint: PublicKeyCredentialHint) -> Self

Adds hint to self iff self doesn’t already contain hint.

§Examples
assert_eq!(
    Hints::EMPTY
        .add(PublicKeyCredentialHint::SecurityKey)
        .first(),
    Some(PublicKeyCredentialHint::SecurityKey)
);
Source

pub const fn first(self) -> Option<PublicKeyCredentialHint>

Returns the first PublicKeyCredentialHint.

§Examples
assert!(Hints::EMPTY.first().is_none());
Source

pub const fn second(self) -> Option<PublicKeyCredentialHint>

Returns the second PublicKeyCredentialHint.

§Examples
assert!(Hints::EMPTY.second().is_none());
Source

pub const fn third(self) -> Option<PublicKeyCredentialHint>

Returns the third PublicKeyCredentialHint.

§Examples
assert!(Hints::EMPTY.third().is_none());
Source

pub const fn count(self) -> u8

Returns the number of PublicKeyCredentialHints in self.

§Examples
assert_eq!(Hints::EMPTY.count(), 0);
Source

pub const fn is_empty(self) -> bool

Returns true iff self is empty.

§Examples
assert!(Hints::EMPTY.is_empty());
Source

pub const fn contains(self, hint: PublicKeyCredentialHint) -> bool

Returns true iff self contains hint.

§Examples
assert!(!Hints::EMPTY.contains(PublicKeyCredentialHint::Hybrid));
Source

pub const fn contains_cross_platform_hints(self) -> bool

Returns true iff self contains a hint that maps to AuthenticatorAttachment::CrossPlatform.

§Examples
assert!(!Hints::EMPTY.contains_platform_hints());
Source

pub const fn contains_platform_hints(self) -> bool

Returns true iff self contains a hint that maps to AuthenticatorAttachment::Platform.

§Examples
assert!(!Hints::EMPTY.contains_platform_hints());

Trait Implementations§

Source§

impl Clone for Hints

Source§

fn clone(&self) -> Self

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 Copy for Hints

Source§

impl Debug for Hints

Source§

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

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

impl Default for Hints

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Hints

Available on crate feature serde only.
Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a sequence based on hints.

Note unknown values will lead to an error.

§Examples
assert_eq!(
    serde_json::from_str::<Hints>(r#"["security-key", "hybrid", "client-device"]"#)?,
    Hints::EMPTY
        .add(PublicKeyCredentialHint::SecurityKey)
        .add(PublicKeyCredentialHint::Hybrid)
        .add(PublicKeyCredentialHint::ClientDevice),
);
assert_eq!(
    serde_json::from_str::<Hints>(r#"["hybrid", "security-key", "client-device"]"#)?,
    Hints::EMPTY
        .add(PublicKeyCredentialHint::Hybrid)
        .add(PublicKeyCredentialHint::SecurityKey)
        .add(PublicKeyCredentialHint::ClientDevice),
);
assert_eq!(
    serde_json::from_str::<Hints>(r#"[]"#)?,
    Hints::EMPTY
);
// Only the first instances are retained while duplicates are ignored.
assert_eq!(
    serde_json::from_str::<Hints>(r#"["hybrid", "client-device", "hybrid"]"#)?,
    Hints::EMPTY
        .add(PublicKeyCredentialHint::Hybrid)
        .add(PublicKeyCredentialHint::ClientDevice)
);
Source§

impl Eq for Hints

Source§

impl PartialEq for Hints

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for Hints

Available on crate feature serde only.
Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes self to conform with hints.

§Examples
assert_eq!(
    serde_json::to_string(&Hints::EMPTY)?,
    r#"[]"#
);
assert_eq!(
    serde_json::to_string(&Hints::EMPTY.add(PublicKeyCredentialHint::SecurityKey))?,
    r#"["security-key"]"#
);
assert_eq!(
    serde_json::to_string(&Hints::EMPTY.add(PublicKeyCredentialHint::ClientDevice))?,
    r#"["client-device"]"#
);
assert_eq!(
    serde_json::to_string(&Hints::EMPTY.add(PublicKeyCredentialHint::Hybrid))?,
    r#"["hybrid"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::ClientDevice)
    )?,
    r#"["security-key","client-device"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::SecurityKey)
    )?,
    r#"["client-device","security-key"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::Hybrid)
    )?,
    r#"["security-key","hybrid"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::SecurityKey)
    )?,
    r#"["hybrid","security-key"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::Hybrid)
    )?,
    r#"["client-device","hybrid"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::ClientDevice)
    )?,
    r#"["hybrid","client-device"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::Hybrid)
    )?,
    r#"["security-key","client-device","hybrid"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::ClientDevice)
    )?,
    r#"["security-key","hybrid","client-device"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::Hybrid)
    )?,
    r#"["client-device","security-key","hybrid"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::SecurityKey)
    )?,
    r#"["client-device","hybrid","security-key"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::SecurityKey)
            .add(PublicKeyCredentialHint::ClientDevice)
    )?,
    r#"["hybrid","security-key","client-device"]"#
);
assert_eq!(
    serde_json::to_string(
        &Hints::EMPTY
            .add(PublicKeyCredentialHint::Hybrid)
            .add(PublicKeyCredentialHint::ClientDevice)
            .add(PublicKeyCredentialHint::SecurityKey)
    )?,
    r#"["hybrid","client-device","security-key"]"#
);
Source§

impl StructuralPartialEq for Hints

Auto Trait Implementations§

§

impl Freeze for Hints

§

impl RefUnwindSafe for Hints

§

impl Send for Hints

§

impl Sync for Hints

§

impl Unpin for Hints

§

impl UnsafeUnpin for Hints

§

impl UnwindSafe for Hints

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.