Skip to main content

FeagiSerializable

Trait FeagiSerializable 

Source
pub trait FeagiSerializable: Debug + Any {
    // Required methods
    fn get_type(&self) -> FeagiByteStructureType;
    fn get_version(&self) -> u8;
    fn get_number_of_bytes_needed(&self) -> usize;
    fn try_serialize_struct_to_byte_slice(
        &self,
        byte_destination: &mut [u8],
    ) -> Result<(), FeagiDataError>;
    fn try_deserialize_and_update_self_from_byte_slice(
        &mut self,
        byte_reading: &[u8],
    ) -> Result<(), FeagiDataError>;
    fn as_any(&self) -> &dyn Any;

    // 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> { ... }
}
Expand description

Trait for structures that can be serialized to and from FEAGI byte format.

Implementations must provide methods for determining their type, version, size requirements, and serialization/deserialization logic. The trait includes default validation methods for type and version checking.

Required Methods§

Source

fn get_type(&self) -> FeagiByteStructureType

Returns the structure type identifier.

Source

fn get_version(&self) -> u8

Returns the version number of this structure format.

Source

fn get_number_of_bytes_needed(&self) -> usize

Returns the total number of bytes needed for serialization.

Source

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

Serializes this structure into the provided byte slice.

The slice must be exactly the size returned by get_number_of_bytes_needed.

Source

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

Deserializes data from a byte slice and updates this structure.

Source

fn as_any(&self) -> &dyn Any

Provide access to Any trait for downcasting

Provided Methods§

Source

fn verify_byte_slice_is_of_correct_type( &self, byte_source: &[u8], ) -> Result<(), FeagiDataError>

Verifies that a byte slice contains data of the correct type.

Source

fn verify_byte_slice_is_of_correct_version( &self, byte_source: &[u8], ) -> Result<(), FeagiDataError>

Verifies that a byte slice contains data of the correct version.

Implementations on Foreign Types§

Source§

impl FeagiSerializable for FeagiJSON

Source§

impl FeagiSerializable for CorticalMappedXYZPNeuronVoxels

Implementors§