pub trait TypeSupport:
'static
+ Send
+ Sync {
// Required methods
fn to_bytes(&self) -> Result<Vec<u8>>;
fn from_bytes(bytes: &[u8]) -> Result<Self>
where Self: Sized;
fn type_name() -> &'static str;
// Provided methods
fn type_support() -> *const c_void { ... }
fn type_hash() -> Result<String> { ... }
}Expand description
Trait for types that have type support information.
This allows the runtime to understand the structure of messages for serialization and deserialization.
§Serialization
The to_bytes and from_bytes methods provide CDR serialization:
- For RCL (DDS-based): Uses
rmw_serialize/rmw_deserializeinternally - For native Zenoh: Uses serde with
cdr-encodingcrate
Required Methods§
Sourcefn from_bytes(bytes: &[u8]) -> Result<Self>where
Self: Sized,
fn from_bytes(bytes: &[u8]) -> Result<Self>where
Self: Sized,
Provided Methods§
Sourcefn type_support() -> *const c_void
fn type_support() -> *const c_void
Returns an opaque pointer to the type support structure.
The actual type of this pointer depends on the implementation
(e.g., rosidl_message_type_support_t in RCL).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.