fixed_map/raw.rs
1//! Raw access to underlying storage.
2//!
3//! This can be useful to implement more efficient serialization, since it might
4//! provide access to smaller primitive values.
5
6/// Trait implemented for storage which can be easily converted to and from a
7/// raw value.
8///
9/// This is implemented for [`SetStorage`] when the `#[key(bitset)]` attribute
10/// is present.
11///
12/// [`SetStorage`]: crate::set::SetStorage
13pub trait RawStorage: Sized {
14 /// The backing raw value.
15 type Value;
16
17 /// Get the raw value of the storage.
18 fn as_raw(&self) -> Self::Value;
19
20 /// Build storage from raw storage.
21 fn from_raw(raw: Self::Value) -> Self;
22}