error.rs (2028B)
1 #[cfg(doc)] 2 use super::{ 3 AuthenticatorSelectionCriteria, CredProtect, CredentialCreationOptions, Extension, 4 PublicKeyCredentialCreationOptions, USER_HANDLE_MAX_LEN, USER_HANDLE_MIN_LEN, UserHandle, 5 UserVerificationRequirement, 6 }; 7 use core::{ 8 error::Error, 9 fmt::{self, Display, Formatter}, 10 }; 11 #[cfg(doc)] 12 use std::time::{Instant, SystemTime}; 13 /// Error returned by [`CredentialCreationOptions::start_ceremony`]. 14 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 15 pub enum CreationOptionsErr { 16 /// Error when [`Extension::prf`] is [`Some`] but [`AuthenticatorSelectionCriteria::user_verification`] is not 17 /// [`UserVerificationRequirement::Required`]. 18 PrfWithoutUserVerification, 19 /// Error when [`Extension::cred_protect`] is [`CredProtect::UserVerificationRequired`] but [`AuthenticatorSelectionCriteria::user_verification`] is not 20 /// [`UserVerificationRequirement::Required`]. 21 CredProtectRequiredWithoutUserVerification, 22 /// Error when [`PublicKeyCredentialCreationOptions::hints`] is not compatible with 23 /// [`AuthenticatorSelectionCriteria::authenticator_attachment`]. 24 HintsIncompatibleWithAuthAttachment, 25 /// [`PublicKeyCredentialCreationOptions::timeout`] could not be added to [`Instant::now`] or [`SystemTime::now`]. 26 InvalidTimeout, 27 } 28 impl Display for CreationOptionsErr { 29 #[inline] 30 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { 31 f.write_str(match *self { 32 Self::PrfWithoutUserVerification => "prf extension was requested without requiring user verification", 33 Self::CredProtectRequiredWithoutUserVerification => "credProtect extension with a value of user verification required was requested without requiring user verification", 34 Self::HintsIncompatibleWithAuthAttachment => "hints are not compatible with the requested authenticator attachment modality", 35 Self::InvalidTimeout => "the timeout could not be added to the current Instant", 36 }) 37 } 38 } 39 impl Error for CreationOptionsErr {}