FeagiSerializable

Trait FeagiSerializable 

Source
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§

Source

fn get_type(&self) -> FeagiByteStructureType

Returns type of structure this is, as defined in the FEAGI Data Serialization Docs

Source

fn get_version(&self) -> u8

Returns the specific version of the structure supported by the current code base

Source

fn get_number_of_bytes_needed(&self) -> usize

Returns the number of bytes needed by be allocated by the FeagiByteContainer when storing the data

Source

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

Source

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§

Source

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

Source

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

Implementations on Foreign Types§

Source§

impl FeagiSerializable for FeagiJSON

Source§

fn get_type(&self) -> FeagiByteStructureType

Source§

fn get_version(&self) -> u8

Source§

fn get_number_of_bytes_needed(&self) -> usize

Source§

fn try_write_to_byte_slice( &self, byte_destination: &mut [u8], ) -> Result<(), FeagiDataError>

Source§

fn try_update_from_byte_slice( &mut self, byte_structure_slice: &[u8], ) -> Result<(), FeagiDataError>

Source§

impl FeagiSerializable for CorticalMappedXYZPNeuronData

Implementors§