Serialize

Trait Serialize 

Source
pub trait Serialize {
    // Required method
    fn to_bytes(&self) -> &[u8];
}
Expand description

Trait for converting types to byte slices.

Enables serialization of structured data for transmission through queues or other byte-oriented communication channels.

§Examples

use osal_rs::os::ToBytes;
 
struct SensorData {
    temperature: i16,
    humidity: u8,
}
 
impl ToBytes for SensorData {
    fn to_bytes(&self) -> &[u8] {
        // Convert struct to bytes
    }
}

Required Methods§

Source

fn to_bytes(&self) -> &[u8]

Converts this value to a byte slice.

§Returns

A reference to the byte representation of this value

Implementors§

Source§

impl<const SIZE: usize> Serialize for Bytes<SIZE>

Available on non-crate feature serde only.

Serialization implementation for Bytes<SIZE> when the serde feature is disabled.

This implementation provides basic serialization by directly returning a reference to the underlying byte array. It’s used when the library is compiled without the serde feature, providing a lightweight alternative serialization mechanism.