Struct K2KTypeRegistry
pub struct K2KTypeRegistry {
by_type_id: HashMap<u64, &'static K2KMessageRegistration>,
by_type_name: HashMap<&'static str, &'static K2KMessageRegistration>,
by_category: HashMap<&'static str, Vec<u64>>,
}Expand description
Registry for discovering K2K-routable message types at runtime.
The registry is built by scanning all K2KMessageRegistration entries
submitted via the inventory crate. This enables runtime discovery of
message types for routing, validation, and monitoring.
§Example
ⓘ
let registry = K2KTypeRegistry::discover();
// Check if a type is routable
if registry.is_routable(501) {
// Allow K2K routing
}
// Get all types in a category
let order_types = registry.get_category("orders");
for type_id in order_types {
println!("Order message type: {}", type_id);
}Fields§
§by_type_id: HashMap<u64, &'static K2KMessageRegistration>§by_type_name: HashMap<&'static str, &'static K2KMessageRegistration>§by_category: HashMap<&'static str, Vec<u64>>Implementations§
§impl K2KTypeRegistry
impl K2KTypeRegistry
pub fn discover() -> K2KTypeRegistry
pub fn discover() -> K2KTypeRegistry
Discover all registered K2K message types at runtime.
This scans all K2KMessageRegistration entries that were submitted
via inventory::submit! during compilation.
pub fn is_routable(&self, type_id: u64) -> bool
pub fn is_routable(&self, type_id: u64) -> bool
Check if a message type ID is K2K routable.
pub fn get(&self, type_id: u64) -> Option<&'static K2KMessageRegistration>
pub fn get(&self, type_id: u64) -> Option<&'static K2KMessageRegistration>
Get registration by type ID.
pub fn get_by_name(
&self,
type_name: &str,
) -> Option<&'static K2KMessageRegistration>
pub fn get_by_name( &self, type_name: &str, ) -> Option<&'static K2KMessageRegistration>
Get registration by type name.
pub fn get_category(&self, category: &str) -> &[u64]
pub fn get_category(&self, category: &str) -> &[u64]
Get all type IDs in a category.
pub fn categories(&self) -> impl Iterator<Item = &'static str>
pub fn categories(&self) -> impl Iterator<Item = &'static str>
Get all registered categories.
pub fn iter(&self) -> impl Iterator<Item = &'static K2KMessageRegistration>
pub fn iter(&self) -> impl Iterator<Item = &'static K2KMessageRegistration>
Iterate all registered message types.
pub fn routable_types(&self) -> Vec<u64>
pub fn routable_types(&self) -> Vec<u64>
Get all routable type IDs.
Trait Implementations§
§impl Debug for K2KTypeRegistry
impl Debug for K2KTypeRegistry
§impl Default for K2KTypeRegistry
impl Default for K2KTypeRegistry
§fn default() -> K2KTypeRegistry
fn default() -> K2KTypeRegistry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for K2KTypeRegistry
impl RefUnwindSafe for K2KTypeRegistry
impl Send for K2KTypeRegistry
impl Sync for K2KTypeRegistry
impl Unpin for K2KTypeRegistry
impl UnwindSafe for K2KTypeRegistry
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.