ctap2-proto: impl AsRef<[u8]> for authenticator::client_pin::PinUvAuthToken

main
Nick Zana 1 year ago
parent 4f589f4525
commit 1872c78347

@ -15,7 +15,6 @@ use raw::{RawRequest, RawResponse};
pub type PinUvAuthParam = [u8; 16]; pub type PinUvAuthParam = [u8; 16];
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum PinUvAuthToken { pub enum PinUvAuthToken {
@ -23,6 +22,15 @@ pub enum PinUvAuthToken {
Long([u8; 32]), Long([u8; 32]),
} }
impl AsRef<[u8]> for PinUvAuthToken {
fn as_ref(&self) -> &[u8] {
match self {
PinUvAuthToken::Short(bytes) => bytes.as_ref(),
PinUvAuthToken::Long(bytes) => bytes.as_ref(),
}
}
}
#[cfg(feature = "serde")] #[cfg(feature = "serde")]
impl TryFrom<&[u8]> for PinUvAuthToken { impl TryFrom<&[u8]> for PinUvAuthToken {
type Error = Error; type Error = Error;

Loading…
Cancel
Save