Skip to main content

Crate nros_serdes

Crate nros_serdes 

Source
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 support
  • alloc — 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
Serialize and Deserialize implementations 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_LEN bytes of dst.