Rename extend_cbor_map_options
This commit is contained in:
@@ -41,32 +41,31 @@ macro_rules! cbor_map_options {
|
|||||||
};
|
};
|
||||||
|
|
||||||
( $( $key:expr => $value:expr ),* ) => {
|
( $( $key:expr => $value:expr ),* ) => {
|
||||||
cbor_extend_map_options! (
|
{
|
||||||
::alloc::collections::BTreeMap::<_, $crate::values::Value>::new(),
|
let mut _map = ::alloc::collections::BTreeMap::<_, $crate::values::Value>::new();
|
||||||
$( $key => $value, )*
|
extend_cbor_map_options! ( &mut _map, $( $key => $value, )* );
|
||||||
)
|
$crate::values::Value::Map(_map)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! cbor_extend_map_options {
|
macro_rules! extend_cbor_map_options {
|
||||||
// Add trailing comma if missing.
|
// Add trailing comma if missing.
|
||||||
( $initial:expr, $( $key:expr => $value:expr ),+ ) => {
|
( &mut $initial:expr, $( $key:expr => $value:expr ),+ ) => {
|
||||||
cbor_extend_map_options! ( $initial, $($key => $value,)+ )
|
extend_cbor_map_options! ( &mut $initial, $($key => $value,)+ )
|
||||||
};
|
};
|
||||||
|
|
||||||
( $initial:expr, $( $key:expr => $value:expr, )* ) => {
|
( &mut $initial:expr, $( $key:expr => $value:expr, )* ) => {
|
||||||
{
|
{
|
||||||
// The import is unused if the list is empty.
|
// The import is unused if the list is empty.
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use $crate::values::{IntoCborKey, IntoCborValueOption};
|
use $crate::values::{IntoCborKey, IntoCborValueOption};
|
||||||
let mut _map = $initial;
|
|
||||||
$(
|
$(
|
||||||
if let Some(val) = $value.into_cbor_value_option() {
|
if let Some(val) = $value.into_cbor_value_option() {
|
||||||
_map.insert($key.into_cbor_key(), val);
|
$initial.insert($key.into_cbor_key(), val);
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
$crate::values::Value::Map(_map)
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,15 +480,17 @@ impl From<PublicKeyCredentialSource> for cbor::Value {
|
|||||||
use PublicKeyCredentialSourceField::*;
|
use PublicKeyCredentialSourceField::*;
|
||||||
let mut private_key = [0; 32];
|
let mut private_key = [0; 32];
|
||||||
credential.private_key.to_bytes(&mut private_key);
|
credential.private_key.to_bytes(&mut private_key);
|
||||||
cbor_extend_map_options! {
|
let mut result = credential.unknown_fields;
|
||||||
credential.unknown_fields,
|
extend_cbor_map_options! {
|
||||||
|
&mut result,
|
||||||
CredentialId => Some(credential.credential_id),
|
CredentialId => Some(credential.credential_id),
|
||||||
PrivateKey => Some(private_key.to_vec()),
|
PrivateKey => Some(private_key.to_vec()),
|
||||||
RpId => Some(credential.rp_id),
|
RpId => Some(credential.rp_id),
|
||||||
UserHandle => Some(credential.user_handle),
|
UserHandle => Some(credential.user_handle),
|
||||||
OtherUi => credential.other_ui,
|
OtherUi => credential.other_ui,
|
||||||
CredRandom => credential.cred_random
|
CredRandom => credential.cred_random
|
||||||
}
|
};
|
||||||
|
cbor::Value::Map(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user