Skip to main content

Module client_hub

Module client_hub 

Source
Expand description

Minimalistic, type-safe ClientHub.

Design goals:

  • Providers register an implementation once (local or remote).
  • Consumers fetch by interface type (trait object): get::<dyn my::Api>().
  • For plugin-like scenarios, multiple implementations of the same interface can coexist under different scopes (e.g. selected by GTS instance ID).

Implementation details:

  • Key = type name. We use type_name::<T>(), which works for T = dyn Trait.
  • Value = Arc<T> stored as Box<dyn Any + Send + Sync> (downcast on read).
  • Sync hot path: get() is non-async; no hidden per-entry cells or lazy slots.

Notes:

  • Re-registering overwrites the previous value atomically; existing Arcs held by consumers remain valid.
  • For testing, just register a mock under the same trait type.

Structs§

ClientHub
Type-safe registry of clients keyed by interface type.
ClientScope
A scope for resolving multiple implementations of the same interface type.
TypeKey
Stable type key for trait objects — uses fully-qualified type_name::<T>().

Enums§

ClientHubError