Function destructure_cbor_map_peek_value

Source
pub fn destructure_cbor_map_peek_value(
    it: &mut Peekable<IntoIter<(Value, Value)>>,
    needle: Value,
) -> Option<Value>
Expand description

This function is an internal detail of the destructure_cbor_map! macro, but has public visibility so that users of the macro can use it.

Given a peekable iterator of key-value pairs sorted in strictly increasing key order and a needle key, this function consumes all items whose key compares less than or equal to the needle, and returns Some(value) if the needle was present as the key in the iterator and None otherwise.

The logic is separated into its own function to reduce binary size, as otherwise the logic would be inlined for every use case. As of June 2020, this saves ~40KB of binary size for the CTAP2 application of OpenSK.