pub trait FeagiSerializable {
// Required methods
fn get_type(&self) -> FeagiByteStructureType;
fn get_version(&self) -> u8;
fn get_number_of_bytes_needed(&self) -> usize;
fn try_write_to_byte_slice(
&self,
byte_destination: &mut [u8],
) -> Result<(), FeagiDataError>;
fn try_update_from_byte_slice(
&mut self,
byte_reading: &[u8],
) -> Result<(), FeagiDataError>;
// Provided methods
fn verify_byte_slice_is_of_correct_type(
&self,
byte_source: &[u8],
) -> Result<(), FeagiDataError> { ... }
fn verify_byte_slice_is_of_correct_version(
&self,
byte_source: &[u8],
) -> Result<(), FeagiDataError> { ... }
}Required Methods§
Sourcefn get_type(&self) -> FeagiByteStructureType
fn get_type(&self) -> FeagiByteStructureType
Returns type of structure this is, as defined in the FEAGI Data Serialization Docs
Sourcefn get_version(&self) -> u8
fn get_version(&self) -> u8
Returns the specific version of the structure supported by the current code base
Sourcefn get_number_of_bytes_needed(&self) -> usize
fn get_number_of_bytes_needed(&self) -> usize
Returns the number of bytes needed by be allocated by the FeagiByteContainer when storing the data
Sourcefn try_write_to_byte_slice(
&self,
byte_destination: &mut [u8],
) -> Result<(), FeagiDataError>
fn try_write_to_byte_slice( &self, byte_destination: &mut [u8], ) -> Result<(), FeagiDataError>
When given a mutable slice of bytes size specified by “get_number_of_bytes_needed”, serialized the struct into it
Sourcefn try_update_from_byte_slice(
&mut self,
byte_reading: &[u8],
) -> Result<(), FeagiDataError>
fn try_update_from_byte_slice( &mut self, byte_reading: &[u8], ) -> Result<(), FeagiDataError>
Given a slice of data of this structure of correct size, Deserialize the slice and update (replace) the data of the structure
Provided Methods§
Sourcefn verify_byte_slice_is_of_correct_type(
&self,
byte_source: &[u8],
) -> Result<(), FeagiDataError>
fn verify_byte_slice_is_of_correct_type( &self, byte_source: &[u8], ) -> Result<(), FeagiDataError>
Verifies that the data slice is of the type expected of the struct
Sourcefn verify_byte_slice_is_of_correct_version(
&self,
byte_source: &[u8],
) -> Result<(), FeagiDataError>
fn verify_byte_slice_is_of_correct_version( &self, byte_source: &[u8], ) -> Result<(), FeagiDataError>
Verifies that the data slice is of the version expected of the struct