1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use borsh::{BorshDeserialize, BorshSerialize};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, BorshSerialize, BorshDeserialize)]
pub enum StorageOutcome {
Inserted([u8; 32]),
Updated([u8; 32]),
Zeroed([u8; 32]),
NonExistentValue([u8; 32]),
ValueExists([u8; 32]),
CapacityExceeded,
Vacant,
Occupied,
}
#[cfg(feature = "heap_available")]
use core::fmt;
#[cfg(feature = "heap_available")]
impl fmt::Debug for StorageOutcome {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"StorageOutcome::{}",
match self {
StorageOutcome::Inserted(value) =>
format!("{}({})", "Inserted", hex::encode(value)),
StorageOutcome::Updated(value) => format!("{}({})", "Updated", hex::encode(value)),
StorageOutcome::Zeroed(value) => format!("{}({})", "Zeroed", hex::encode(value)),
StorageOutcome::NonExistentValue(value) =>
format!("{}({})", "NonExistentValue", hex::encode(value)),
StorageOutcome::ValueExists(value) =>
format!("{}({})", "ValueExists", hex::encode(value)),
StorageOutcome::CapacityExceeded => format!("{}", "CapacityExceeded"),
StorageOutcome::Vacant => format!("{}", "Vacant"),
StorageOutcome::Occupied => format!("{}", "Occupied"),
}
)
}
}