pub enum RosPrimitive {
Show 15 variants
Bool,
Byte,
Char,
Int8,
Uint8,
Int16,
Uint16,
Int32,
Uint32,
Int64,
Uint64,
Float32,
Float64,
String,
Wstring,
}Expand description
Strongly-typed enum of every ROS2 IDL primitive. This is the
single source of truth for how a primitive maps to wire formats
across generators. Both proto_gen and mcp_python_gen consume
the methods on this enum so a new primitive only has to be added
here once.
The catch-all silent fallbacks that used to live in each generator
(_ => "int", _ => "bytes") are gone — every primitive must be
listed explicitly. An unrecognised type now panics at codegen time
instead of silently producing the wrong wire shape.
Variants§
Implementations§
Source§impl RosPrimitive
impl RosPrimitive
pub fn parse(s: &str) -> Option<Self>
pub fn as_ros_str(&self) -> &'static str
Sourcepub fn proto_type(&self) -> &'static str
pub fn proto_type(&self) -> &'static str
proto3 wire type for this primitive.
Sourcepub fn python_type(&self) -> &'static str
pub fn python_type(&self) -> &'static str
Python type name used in MCP dataclass annotations.
Sourcepub fn python_default(&self) -> &'static str
pub fn python_default(&self) -> &'static str
Default literal in Python for a non-array field.
Sourcepub fn python_cast(&self) -> &'static str
pub fn python_cast(&self) -> &'static str
Python cast invoked by from_dict() when validating an inbound
JSON value. Same as the type name for builtin casts.
Sourcepub fn json_schema_type(&self) -> &'static str
pub fn json_schema_type(&self) -> &'static str
JSON Schema base type (“integer” / “number” / “boolean” / “string”).
Sourcepub fn integer_range(&self) -> Option<(i128, i128)>
pub fn integer_range(&self) -> Option<(i128, i128)>
Inclusive range constraint for integer primitives (used by
from_dict validation and JSON Schema minimum/maximum).
Floats / strings / bool return None — JSON Schema’s defaults
already cover them.
Sourcepub fn is_blob_element(&self) -> bool
pub fn is_blob_element(&self) -> bool
True if this primitive is the canonical “raw byte buffer” type.
Only uint8 qualifies — byte is signed 8-bit and shouldn’t
be conflated. Used by both proto and MCP gens to decide whether
a T[] field becomes a wire-level byte blob (bytes in proto,
base64-encoded bytes in MCP).
Trait Implementations§
Source§impl Clone for RosPrimitive
impl Clone for RosPrimitive
Source§fn clone(&self) -> RosPrimitive
fn clone(&self) -> RosPrimitive
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more