pub trait Storable: Sized {
// Required methods
fn encode<T>(&self, dest: &mut T)
where T: Output + ?Sized;
fn decode<I>(input: &mut I) -> Result<Self, Error>
where I: Input;
fn encoded_size(&self) -> usize;
}
Expand description
Trait for representing types which can be read and written to storage.
This trait is not the same as the [scale::Codec
]. Each type that implements
[scale::Codec
] are storable by default and transferable between contracts.
But not each storable type is transferable.
Required Methods§
fn encode<T>(&self, dest: &mut T)where
T: Output + ?Sized,
fn encode<T>(&self, dest: &mut T)where T: Output + ?Sized,
Convert self to a slice and append it to the destination.
fn decode<I>(input: &mut I) -> Result<Self, Error>where
I: Input,
fn decode<I>(input: &mut I) -> Result<Self, Error>where I: Input,
Attempt to deserialize the value from input.
fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
The exact number of bytes this type consumes in the encoded form.
Object Safety§
This trait is not object safe.
Implementors§
impl<K, V, KeyType> Storable for Mapping<K, V, KeyType>where V: Packed, KeyType: StorageKey,
impl<P> Storable for Pwhere P: Codec,
Types which implement scale::Encode
and scale::Decode
are Storable
by default
because they can be written directly into the storage cell.