error.rs (1621B)
1 #[cfg(doc)] 2 use super::{ 3 AllowedCredentials, CredentialSpecificExtension, Extension, PublicKeyCredentialRequestOptions, 4 UserVerificationRequirement, 5 }; 6 use core::{ 7 error::Error, 8 fmt::{self, Display, Formatter}, 9 }; 10 #[cfg(doc)] 11 use std::time::{Instant, SystemTime}; 12 /// Error returned from [`PublicKeyCredentialRequestOptions::second_factor`] when 13 /// [`AllowedCredentials`] is empty. 14 #[derive(Clone, Copy, Debug)] 15 pub struct SecondFactorErr; 16 impl Display for SecondFactorErr { 17 #[inline] 18 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { 19 f.write_str("allowed credentials was empty") 20 } 21 } 22 impl Error for SecondFactorErr {} 23 /// Error returned by [`PublicKeyCredentialRequestOptions::start_ceremony`]. 24 #[derive(Clone, Copy, Debug)] 25 pub enum RequestOptionsErr { 26 /// Error when [`Extension::prf`] or [`CredentialSpecificExtension::prf`] is [`Some`] but 27 /// [`PublicKeyCredentialRequestOptions::user_verification`] is not 28 /// [`UserVerificationRequirement::Required`]. 29 PrfWithoutUserVerification, 30 /// [`PublicKeyCredentialRequestOptions::timeout`] could not be added to [`Instant::now`] or [`SystemTime::now`]. 31 InvalidTimeout, 32 } 33 impl Display for RequestOptionsErr { 34 #[inline] 35 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { 36 f.write_str(match *self { 37 Self::PrfWithoutUserVerification => { 38 "prf extension was requested without requiring user verification" 39 } 40 Self::InvalidTimeout => "the timeout could not be added to the current Instant", 41 }) 42 } 43 } 44 impl Error for RequestOptionsErr {}