pub trait DurableType: Sized {
type Key;
type Value;
// Required methods
fn into_key_value(self) -> (Self::Key, Self::Value);
fn from_key_value(key: Self::Key, value: Self::Value) -> Self;
fn key(&self) -> Self::Key;
}
Expand description
A trait for representing Self
as a key-value pair of type
(Key, Value)
for the purpose of storing this value durably.
To encode a key-value pair, use DurableType::into_key_value
.
To decode a key-value pair, use DurableType::from_key_value
.
This trait is based on RustType
, however it is meant to
convert the types used in RustType
to a more consumable and
condensed type.
Required Associated Types§
Required Methods§
Sourcefn into_key_value(self) -> (Self::Key, Self::Value)
fn into_key_value(self) -> (Self::Key, Self::Value)
Consume and convert Self
into a (Key, Value)
key-value pair.
Sourcefn from_key_value(key: Self::Key, value: Self::Value) -> Self
fn from_key_value(key: Self::Key, value: Self::Value) -> Self
Consume and convert a (Key, Value)
key-value pair back into a
Self
value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.