From 4e416bdb56fe392514a4941adc644c26528516b9 Mon Sep 17 00:00:00 2001 From: "John M. Schanck" Date: Mon, 21 Aug 2023 16:45:36 -0700 Subject: [PATCH] Add AuthenticatorData::to_vec --- src/ctap2/attestation.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/ctap2/attestation.rs b/src/ctap2/attestation.rs index 15e1562..c8bf67c 100644 --- a/src/ctap2/attestation.rs +++ b/src/ctap2/attestation.rs @@ -205,6 +205,15 @@ pub struct AuthenticatorData { pub extensions: Extension, } +impl AuthenticatorData { + pub fn to_vec(&self) -> Vec { + match serde_cbor::value::to_value(self) { + Ok(serde_cbor::value::Value::Bytes(out)) => out, + _ => unreachable!(), // Serialize is guaranteed to produce bytes + } + } +} + impl<'de> Deserialize<'de> for AuthenticatorData { fn deserialize(deserializer: D) -> Result where