mirror of
https://github.com/trussed-dev/cbor-smol.git
synced 2026-06-20 04:17:03 -07:00
deserialize_identifier: add support for all types expected by serde
The default serde deserialize derive accepts 3 types for identifiers: - The name of the field as `str` - The name of the field as ascii bytes - The index of the field as u64 This PR changes deserialize_identifier to have compatibility with all of these This is necessary for https://github.com/Nitrokey/fido-authenticator/issues/57, which needs compatibility with both the str variant and the index variant
This commit is contained in:
committed by
sosthene-nitrokey
parent
6b3ce6928e
commit
c48b2b29df
@@ -806,7 +806,13 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
||||
where
|
||||
V: Visitor<'de>,
|
||||
{
|
||||
self.deserialize_str(visitor)
|
||||
let major = self.peek_major()?;
|
||||
match major {
|
||||
MAJOR_STR => self.deserialize_str(visitor),
|
||||
MAJOR_POSINT => self.deserialize_u64(visitor),
|
||||
MAJOR_BYTES => self.deserialize_bytes(visitor),
|
||||
_ => Err(Error::DeserializeBadMajor),
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_ignored_any<V>(self, visitor: V) -> Result<V::Value>
|
||||
|
||||
Reference in New Issue
Block a user