Expand description
CDR serialization/deserialization for nros.
Implements OMG Common Data Representation (CDR) encoding compatible with ROS 2. All types use little-endian byte order with natural alignment.
§Examples
use nros_serdes::{CdrReader, CdrWriter, DeserError, Deserialize, SerError, Serialize};
// Serialize a u32 into a CDR buffer
let mut buf = [0u8; 64];
let mut writer = CdrWriter::new_with_header(&mut buf).unwrap();
42u32.serialize(&mut writer).unwrap();
let len = writer.position();
// Deserialize it back
let mut reader = CdrReader::new_with_header(&buf[..len]).unwrap();
let value = u32::deserialize(&mut reader).unwrap();
assert_eq!(value, 42);§Features
std— Enable standard library supportalloc— Enable heap allocation (String,Vec<T>)
Re-exports§
pub use cdr::CdrReader;pub use cdr::CdrWriter;pub use cdr::LeDecode;pub use cdr::LeSliceView;pub use error::DeserError;pub use error::SerError;pub use schema::Field;pub use schema::FieldType;pub use schema::Message;pub use schema::NestedType;pub use traits::Deserialize;pub use traits::DeserializeBorrowed;pub use traits::Serialize;
Modules§
- cdr
- CDR encoder/decoder with alignment handling
- error
- Error types for CDR serialization and deserialization.
- primitives
SerializeandDeserializeimplementations for primitive types.- schema
- Static field schema for runtime introspection.
- traits
- Serialization traits
Constants§
- CDR_
BE_ HEADER - CDR encapsulation header for big-endian encoding
- CDR_
HEADER_ LEN - Length of the CDR encapsulation header (representation identifier + options).
- CDR_
LE_ HEADER - CDR encapsulation header for little-endian encoding
Functions§
- strip_
cdr_ header - Strip the CDR encapsulation header from
src, returning the payload slice. - write_
cdr_ le_ header - Write the little-endian CDR header into the first
CDR_HEADER_LENbytes ofdst.