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.
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.