pub trait SecNanosecMsg: Sized {
// Required method
fn from_sec_nanosec(sec: i32, nanosec: u32) -> Self;
}Expand description
A generated message whose field set is { sec: i32, nanosec: u32 } —
builtin_interfaces/msg/Time and its Duration twin.
This is the Rust substitute for a C++ template parameter. nros-cpp
spells the same conversion as
template <typename TimeMsgT> void Time::to_msg(TimeMsgT&)
(packages/api/nros-cpp/include/rclcpp/time.hpp), which binds structurally to
anything carrying sec / nanosec. Rust has no structural bound, so the same
trick needs an AUTHORED trait that rosidl-codegen implements for every
generated message with that exact field set — the same binding set the C++
template has, decided by SHAPE rather than by a hard-coded package name.
Why the trait lives here and the impl does not: nros-core can never name a
message type. Every generated message crate depends on nros-core, so a
dependency the other way is a cycle, and message types are generated per USER
package (RFC-0023 / RFC-0067) — there is no one crate for the client library
to name. The trait is the seam that lets the conversion cross that edge
without an edge.
Implemented by codegen; nothing in this crate implements it.
Required Methods§
Sourcefn from_sec_nanosec(sec: i32, nanosec: u32) -> Self
fn from_sec_nanosec(sec: i32, nanosec: u32) -> Self
Build the message from an already-decomposed timestamp.
Infallible by construction — both components are already the message’s
own field types. See Time::to_ros_msg for why no Result appears
here.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".