commonware_storage/qmdb/any/
value.rs1use commonware_codec::{CodecFixedShared, CodecShared};
4use std::marker::PhantomData;
5
6mod sealed {
7 use commonware_codec::CodecShared;
8
9 pub trait ValueEncoding: Clone + Send + Sync {
14 type Value: CodecShared + Clone;
16 }
17}
18
19pub use sealed::ValueEncoding;
20
21#[derive(Clone, Debug, PartialEq, Eq)]
23pub struct FixedEncoding<V: FixedValue>(PhantomData<V>);
24
25impl<V: FixedValue> sealed::ValueEncoding for FixedEncoding<V> {
26 type Value = V;
27}
28
29#[derive(Clone, Debug, PartialEq, Eq)]
31pub struct VariableEncoding<V: VariableValue>(PhantomData<V>);
32
33impl<V: VariableValue> sealed::ValueEncoding for VariableEncoding<V> {
34 type Value = V;
35}
36
37pub trait FixedValue: CodecFixedShared + Clone {}
39impl<T: CodecFixedShared + Clone> FixedValue for T {}
40
41pub trait VariableValue: CodecShared + Clone {}
43impl<T: CodecShared + Clone> VariableValue for T {}