pub struct TypeRegistry { /* private fields */ }Expand description
Type registry: caches every type resolved so far, by name.
Implementations§
Source§impl TypeRegistry
impl TypeRegistry
Sourcepub fn get(&self, type_name: &str) -> Option<ResolvedType>
pub fn get(&self, type_name: &str) -> Option<ResolvedType>
A previously resolved type, if any.
Sourcepub fn insert(&self, type_name: &str, resolved: ResolvedType)
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).
Sourcepub fn load_idl_file(
&self,
idl_path: &Path,
type_name: &str,
) -> Result<ResolvedType, TypeResolveError>
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.
Sourcepub fn load_xml_file(
&self,
xml_path: &Path,
type_name: &str,
) -> Result<ResolvedType, TypeResolveError>
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).
Sourcepub fn resolve_discovered(
&self,
runtime: &DcpsRuntime,
type_name: &str,
hash: EquivalenceHash,
) -> Result<ResolvedType, TypeResolveError>
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.
Sourcepub fn resolve_named(
&self,
runtime: &DcpsRuntime,
topic_name: &str,
type_name: &str,
timeout: Duration,
) -> Result<ResolvedType, TypeResolveError>
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.
Sourcepub fn resolve_synthetic(
&self,
type_name: &str,
root: CompleteTypeObject,
dependencies: Vec<CompleteTypeObject>,
) -> Result<ResolvedType, TypeResolveError>
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.