pub trait Deserialize: Sized {
// Required method
fn decode_static<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>;
// Provided methods
fn decode<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error> { ... }
fn decode_dynamic<I: Input + ?Sized>(
&mut self,
_buffer: &mut I,
) -> Result<(), Error> { ... }
fn from_bytes(buffer: &[u8]) -> Result<Self, Error> { ... }
}
Expand description
Allows deserialize the type from the Input
.
https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/tx_format.md#transaction
Required Methods§
Provided Methods§
sourcefn decode<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
fn decode<I: Input + ?Sized>(buffer: &mut I) -> Result<Self, Error>
Decodes Self
from the buffer
.
It is better to not implement this function directly, instead implement
decode_static
and decode_dynamic
.
sourcefn decode_dynamic<I: Input + ?Sized>(
&mut self,
_buffer: &mut I,
) -> Result<(), Error>
fn decode_dynamic<I: Input + ?Sized>( &mut self, _buffer: &mut I, ) -> Result<(), Error>
Decodes dynamic part of the information from the buffer
to fill Self
.
The default implementation does nothing. Dynamically-sized contains should
override this.
sourcefn from_bytes(buffer: &[u8]) -> Result<Self, Error>
fn from_bytes(buffer: &[u8]) -> Result<Self, Error>
Helper method for deserializing Self
from bytes.
Object Safety§
This trait is not object safe.