diff --git a/CHANGELOG.md b/CHANGELOG.md index 714b524..200376a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove unused `Rpc` trait. - Remove `cbor-smol` re-export as `serde`. - Make `ctap2::CtapMappingError` private. +- Set `#[repr(u8)]` for `ctap2::Error` and implement `From` for `u8`. ## [0.6.0-rc.4] 2026-06-01 diff --git a/src/ctap2.rs b/src/ctap2.rs index 972e95d..3a07a0e 100644 --- a/src/ctap2.rs +++ b/src/ctap2.rs @@ -444,6 +444,7 @@ impl<'de> Deserialize<'de> for AttestationFormatsPreference { #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[non_exhaustive] +#[repr(u8)] pub enum Error { Success = 0x00, InvalidCommand = 0x01, @@ -502,6 +503,12 @@ pub enum Error { VendorLast = 0xFF, } +impl From for u8 { + fn from(error: Error) -> u8 { + error as _ + } +} + /// CTAP2 authenticator API pub trait Authenticator { fn get_info(&mut self) -> get_info::Response;