Skip to main content

MetadataRecorder

Struct MetadataRecorder 

Source
pub struct MetadataRecorder<const MAX_NODES: usize = DEFAULT_MAX_METADATA_NODES, const MAX_ENTITIES: usize = DEFAULT_MAX_METADATA_ENTITIES, const MAX_CALLBACKS: usize = DEFAULT_MAX_METADATA_CALLBACKS> { /* private fields */ }
Expand description

In-memory metadata sink used by host discovery. It never opens transport.

With alloc (every host producer) it records any number of nodes, entities and callback effects, and the const parameters are unused. Without alloc they are fixed capacities, and a full recorder refuses with NodeMetadataError::Capacity.

Implementations§

Source§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

Source

pub const fn new() -> Self

Create an empty metadata recorder.

Source

pub fn arm_parameter_declarations(&mut self)

Start watching parameter declarations: from now on the sidecar states whether its parameters list is complete. Idempotent; a broken watch stays broken.

Source

pub fn break_parameter_declarations(&mut self)

The parameters list can no longer be the whole declaration set: a row was refused, or a node opted into undeclared parameters. Ignored unless the watch is armed, since an unwatched recorder says nothing.

Source

pub fn parameter_declarations_watched(&self) -> Option<bool>

Some(true) when the recorded parameters are the whole declaration set, Some(false) when the watch broke, None when nothing watched.

Source

pub fn arm_descriptor_text(&mut self)

Start watching descriptor prose: from now on the sidecar states the longest description and constraints text seen, 0 for one never set. Idempotent; keeps what was seen.

Source

pub fn observe_descriptor_text(&mut self, constraints: bool, len: usize)

The code set a description (constraints == false) or an additional_constraints text of len bytes. Ignored unless arm_descriptor_text ran: an unarmed recorder states nothing about prose.

Source

pub fn description_max_len(&self) -> Option<usize>

The longest description seen, or None when nothing watched.

Source

pub fn constraints_max_len(&self) -> Option<usize>

The longest additional_constraints seen, or None when nothing watched.

Source

pub fn nodes(&self) -> &[NodeMetadata]

Recorded nodes in declaration order.

Source

pub fn entities(&self) -> &[EntityMetadata]

Recorded entities in declaration order.

Source

pub fn callback_effects(&self) -> &[CallbackEffectMetadata]

Recorded optional callback effects in declaration order.

Source

pub fn observe_lifecycle_registration( &mut self, name: &str, namespace: &str, ) -> bool

Attach an OBSERVED registration fact to the subscription row that registered it.

A subscription is recorded when the backend creates it and observed when the executor registers it, which are two moments in one call — the RMW seam runs inside Executor::open_subscription. So the row exists and the fact arrives afterwards; this is the join.

Keyed on (source_name, type_name) and taking the LAST unset match, which is the row that was just created: two subscriptions on one topic of one type are indistinguishable at this seam, and taking them in order is the only attribution available. Returns false when no such row is waiting — a caller that drops that has silently lost a fact, which is why this is #[must_use] like every other recorder entry point.

Refuses to overwrite. A row whose fact is already set is not a match, so a second observation lands on the next unset row rather than re-stating the first — the difference matters exactly when two rows disagree, which is the case this whole field exists for. The join for a lifecycle registration: mark the recorded node the executor named as code-managed.

Matched on the final name and on the namespace without its leading and trailing / (the executor’s managed_node_id rule), so "", / and / + / are one root namespace. Returns false when no recorded node matches: a registration the sidecar cannot attribute is a fact lost, and the caller must say so rather than drop it.

Source

pub fn observe_subscription_registration( &mut self, source_name: &str, type_name: &str, in_place_capable: bool, buffered_row: BufferedRow, ) -> bool

Source

pub fn to_source_metadata_json( &self, export: &SourceMetadataExport<'_>, ) -> Result<StdString, Error>

Emit source metadata JSON (SOURCE_METADATA_SCHEMA_VERSION) without opening transport.

Source

pub fn write_source_metadata_json( &self, export: &SourceMetadataExport<'_>, out: &mut impl Write, ) -> Result

Write source metadata JSON (SOURCE_METADATA_SCHEMA_VERSION) without opening transport.

Source

pub fn push_node( &mut self, id: NodeId<'_>, name: &str, namespace: &str, domain_id: u32, ) -> Result<(), NodeMetadataError>

Record a node.

pub because the recorder is the ONE recorder: the Rust adapter (a NodeContext sink) and the C/C++ adapter (a recording RMW backend + the timer/guard hooks in nros-cpp) both feed it, so there is one definition of what a slot is and one schema emitter. Only the adapter is per-language. Not a general-purpose API — it exists for metadata-mode adapters, and misuse produces a sidecar that lies about what the component declares.

Source

pub fn push_entity( &mut self, entity: EntityMetadata, ) -> Result<(), NodeMetadataError>

Record an entity against an already-recorded node. See push_node for why this is public.

Trait Implementations§

Source§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Debug for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

Source§

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

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

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Default for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> NodeRuntime for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

Source§

fn create_node( &mut self, id: NodeId<'_>, options: NodeOptions<'_>, ) -> NodeResult<()>

Declare a component node.
Source§

fn create_entity(&mut self, metadata: EntityMetadata) -> NodeResult<()>

Declare a publisher, subscription, timer, service, action, or parameter.
Source§

fn record_callback_effect( &mut self, callback_id: CallbackId<'_>, kind: CallbackEffectKind, entity_id: EntityId<'_>, ) -> NodeResult<()>

Add optional callback effect metadata.

Auto Trait Implementations§

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Freeze for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> RefUnwindSafe for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Send for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Sync for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> Unpin for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> UnsafeUnpin for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

§

impl<const MAX_NODES: usize, const MAX_ENTITIES: usize, const MAX_CALLBACKS: usize> UnwindSafe for MetadataRecorder<MAX_NODES, MAX_ENTITIES, MAX_CALLBACKS>

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> 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, 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.