Skip to main content

TypeRegistry

Struct TypeRegistry 

Source
pub struct TypeRegistry { /* private fields */ }
Expand description

Type registry: caches every type resolved so far, by name.

Implementations§

Source§

impl TypeRegistry

Source

pub fn new() -> Self

Empty registry.

Source

pub fn get(&self, type_name: &str) -> Option<ResolvedType>

A previously resolved type, if any.

Source

pub fn insert(&self, type_name: &str, resolved: ResolvedType)

Registers an already-resolved type under its name (idempotent — a later call with the same name replaces the entry, since the daemon reloads its config on SIGHUP).

Source

pub fn load_idl_file( &self, idl_path: &Path, type_name: &str, ) -> Result<ResolvedType, TypeResolveError>

Parses idl_path, resolves type_name in it, and registers the result. type_name is the IDL scoped name (Mod::Type), which is also the DDS type_name samples of this topic carry on the wire.

§Errors

See TypeResolveError.

Source

pub fn load_xml_file( &self, xml_path: &Path, type_name: &str, ) -> Result<ResolvedType, TypeResolveError>

Parses xml_path as a DDS-XML 1.0 <types>/<dds> document (zerodds_xml::parse_type_libraries), resolves type_name in it (a top-level, or module-flattened Outer::Inner, name) and registers the result. Every other type the library declares is offered as a dependency (SerializedTypeSupport only uses what it needs) — the same “offer the whole model” shape Self::load_idl_file uses for the IDL front end.

§Errors

TypeResolveError::Io if the file cannot be read. TypeResolveError::Idl if it does not parse as DDS-XML, or declares no <types> library at all. TypeResolveError::NotFound if type_name is not among the library’s (flattened) type names. TypeResolveError::Model if the bridge to CompleteTypeObject refuses a construct (zerodds_xml::typeobject_bridge’s documented gaps — a named sequence/array typedef, for one).

Source

pub fn resolve_discovered( &self, runtime: &DcpsRuntime, type_name: &str, hash: EquivalenceHash, ) -> Result<ResolvedType, TypeResolveError>

Resolves type_name from a discovered hash once the participant’s DcpsRuntime TypeLookup registry holds its CompleteTypeObject (own register_type_object calls, getTypes replies from a peer, or send_type_lookup_request having completed). Caches the result under type_name.

§Errors

TypeResolveError::NotYetResolved if the registry does not (yet) hold the hash’s complete object — the caller should retry after issuing/awaiting DcpsRuntime::send_type_lookup_request.

Source

pub fn resolve_named( &self, runtime: &DcpsRuntime, topic_name: &str, type_name: &str, timeout: Duration, ) -> Result<ResolvedType, TypeResolveError>

Resolves type_name for topic_name automatically: if a discovered publication or subscription names topic_name, its SEDP-announced TypeIdentifier is asked for from the peer that owns it (DcpsRuntime::send_type_lookup_request) and awaited, bounded by timeout. The wait is generation-driven, not a bare sleep loop: zerodds_types::resolve::TypeRegistry::generation is read every tick, and the (cheap) resolve attempt against the registry only re-runs when it has moved since the last one — the same short-circuit DcpsRuntime’s own receive path uses (UserReaderSlot::resolve_key_hash_support) to avoid rebuilding a model on every tick a reply has not (yet) landed.

A response arrives on the receive thread via a callback that only ever updates the registry (DcpsRuntime has no dedicated wake signal for a TypeLookup reply the way WaitSet’s samples do) — this is the boundedly-polled substitute for a zero-poll wait; see the crate README “Open points”.

§Errors

TypeResolveError::NoDiscoveredEndpoint if nothing discovered names topic_name at all (there is then no TypeIdentifier to even ask about). TypeResolveError::TimedOut if a request was sent and awaited but the type never resolved within timeout.

Source

pub fn resolve_synthetic( &self, type_name: &str, root: CompleteTypeObject, dependencies: Vec<CompleteTypeObject>, ) -> Result<ResolvedType, TypeResolveError>

Registers a CompleteTypeObject this crate synthesized itself (not read from an IDL file, an XML <types> document, or TypeLookup) — crate::rpc_dispatch’s per-operation In/Out structs, DDS-RPC 1.0 §7.5.1.1.4/§7.5.1.1.5, built from an operation’s parameter list via zerodds_types::from_ast::type_identifier. Goes through the same resolve_from_complete every other source does, so a synthetic type is validated (its keyed/extensibility read off itself, never asserted by the caller) exactly like a discovered or file-loaded one.

§Errors

See TypeResolveError.

Trait Implementations§

Source§

impl Default for TypeRegistry

Source§

fn default() -> Self

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

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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.