Skip to main content

RosPrimitive

Enum RosPrimitive 

Source
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§

§

Bool

§

Byte

§

Char

§

Int8

§

Uint8

§

Int16

§

Uint16

§

Int32

§

Uint32

§

Int64

§

Uint64

§

Float32

§

Float64

§

String

§

Wstring

Implementations§

Source§

impl RosPrimitive

Source

pub fn parse(s: &str) -> Option<Self>

Source

pub fn as_ros_str(&self) -> &'static str

Source

pub fn proto_type(&self) -> &'static str

proto3 wire type for this primitive.

Source

pub fn python_type(&self) -> &'static str

Python type name used in MCP dataclass annotations.

Source

pub fn python_default(&self) -> &'static str

Default literal in Python for a non-array field.

Source

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.

Source

pub fn json_schema_type(&self) -> &'static str

JSON Schema base type (“integer” / “number” / “boolean” / “string”).

Source

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.

Source

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

Source§

fn clone(&self) -> RosPrimitive

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RosPrimitive

Source§

impl Debug for RosPrimitive

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for RosPrimitive

Source§

impl Hash for RosPrimitive

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for RosPrimitive

Source§

fn eq(&self, other: &RosPrimitive) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for RosPrimitive

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.