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§
Implementors§
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.