Trait fuel_core_storage::codec::Encode
source · pub trait Encode<T: ?Sized> {
type Encoder<'a>: Encoder
where T: 'a;
// Required method
fn encode(t: &T) -> Self::Encoder<'_>;
// Provided method
fn encode_as_value(t: &T) -> Value { ... }
}
Expand description
The trait encodes the type to the bytes and passes it to the Encoder
,
which stores it and provides a reference to it. That allows gives more
flexibility and more performant encoding, allowing the use of slices and arrays
instead of vectors in some cases. Since the Encoder
returns Cow<[u8]>
,
it is always possible to take ownership of the serialized value.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn encode_as_value(t: &T) -> Value
fn encode_as_value(t: &T) -> Value
Returns the serialized object as an Value
.
Object Safety§
This trait is not object safe.