pub trait Serialize {
// Required methods
fn size_static(&self) -> usize;
fn size_dynamic(&self) -> usize;
fn encode_static<O: Output + ?Sized>(
&self,
buffer: &mut O,
) -> Result<(), Error>;
// Provided methods
fn size(&self) -> usize { ... }
fn encode<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error> { ... }
fn encode_dynamic<O: Output + ?Sized>(
&self,
_buffer: &mut O,
) -> Result<(), Error> { ... }
fn to_bytes(&self) -> Vec<u8> { ... }
}
Expand description
Allows serialize the type into the Output
.
https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/tx_format.md#transaction
Required Methods§
sourcefn size_static(&self) -> usize
fn size_static(&self) -> usize
Size of the static part of the serialized object, in bytes. Saturates to usize::MAX on overflow.
sourcefn size_dynamic(&self) -> usize
fn size_dynamic(&self) -> usize
Size of the dynamic part, in bytes. Saturates to usize::MAX on overflow.
Provided Methods§
sourcefn size(&self) -> usize
fn size(&self) -> usize
Total size of the serialized object, in bytes. Saturates to usize::MAX on overflow.
sourcefn encode<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
fn encode<O: Output + ?Sized>(&self, buffer: &mut O) -> Result<(), Error>
Encodes Self
into the buffer
.
It is better to not implement this function directly, instead implement
encode_static
and encode_dynamic
.
Object Safety§
This trait is not object safe.