1use zeroize::{Zeroize, ZeroizeOnDrop};
6
7#[derive(PartialEq)]
12#[non_exhaustive]
13pub enum CborValue {
14 Null,
16 Bool(bool),
18 Int(i64),
20 String(String),
22 Bytes(Vec<u8>),
24 Array(Vec<CborValue>),
26 Map(Vec<(String, CborValue)>),
28}
29
30impl core::fmt::Debug for CborValue {
31 fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
32 let kind = match self {
33 Self::Null => "Null",
34 Self::Bool(_) => "Bool",
35 Self::Int(_) => "Int",
36 Self::String(_) => "String",
37 Self::Bytes(_) => "Bytes",
38 Self::Array(_) => "Array",
39 Self::Map(_) => "Map",
40 };
41 formatter.debug_tuple("CborValue").field(&kind).finish()
42 }
43}
44
45impl Zeroize for CborValue {
47 fn zeroize(&mut self) {
48 match self {
49 Self::Null => {}
50 Self::Bool(value) => value.zeroize(),
51 Self::Int(value) => value.zeroize(),
52 Self::String(value) => value.zeroize(),
53 Self::Bytes(value) => value.zeroize(),
54 Self::Array(values) => values.zeroize(),
55 Self::Map(entries) => entries.zeroize(),
56 }
57 }
58}
59
60impl Drop for CborValue {
61 fn drop(&mut self) {
62 self.zeroize();
63 }
64}
65
66impl ZeroizeOnDrop for CborValue {}