From 542a3b9b77cf6cc35ddc0523076365427fb24cff Mon Sep 17 00:00:00 2001 From: Nick Zana Date: Tue, 16 May 2023 19:15:29 -0400 Subject: [PATCH] ctap2-proto: Derive serde types for UsizeN Just a wrapper struct around bounded_integer::BoundedUsize the bounded_integer/serde1 feature needs to be enabled. --- crates/ctap2-proto/Cargo.toml | 2 +- crates/ctap2-proto/src/authenticator/device.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ctap2-proto/Cargo.toml b/crates/ctap2-proto/Cargo.toml index 5139203..64aa113 100644 --- a/crates/ctap2-proto/Cargo.toml +++ b/crates/ctap2-proto/Cargo.toml @@ -12,4 +12,4 @@ coset = "0.3.3" serde = { version = "1.0", features = ["derive"], optional = true } [features] -serde = ["dep:serde", "fido-common/serde"] +serde = ["dep:serde", "fido-common/serde", "bounded-integer/serde1"] diff --git a/crates/ctap2-proto/src/authenticator/device.rs b/crates/ctap2-proto/src/authenticator/device.rs index a861799..0fe6166 100644 --- a/crates/ctap2-proto/src/authenticator/device.rs +++ b/crates/ctap2-proto/src/authenticator/device.rs @@ -7,8 +7,12 @@ use std::collections::{BTreeMap, BTreeSet}; use std::num::NonZeroUsize; use std::usize; +#[cfg(feature = "serde")] +use serde::{Deserialize, Serialize}; + /// A usize with a minimum value of N #[derive(Debug, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct UsizeN(bounded_integer::BoundedUsize); /// > data type byte string and identifying the authenticator model, i.e.