Skip to main content

TypeRegistry

Struct TypeRegistry 

Source
pub struct TypeRegistry { /* private fields */ }
Available on crate features json or text only.
Expand description

Unified registry: JSON Any + extension entries (under json) and text Any + extension entries (under text).

Populate with generated register_types(&mut reg) functions, then install once with set_type_registry. The JSON half delegates to the existing AnyRegistry and ExtensionRegistry types; the text half uses parallel maps. Both axes’ lookup indirection (by_nameby_number) is preserved.

Implementations§

Source§

impl TypeRegistry

Source

pub fn new() -> Self

Creates an empty registry.

Source

pub fn register_json_any(&mut self, entry: JsonAnyEntry)

Available on crate feature json only.

Registers a JSON Any type entry. Replaces any existing entry for the same type URL.

Source

pub fn register_json_ext(&mut self, entry: JsonExtEntry)

Available on crate feature json only.

Registers a JSON extension entry. Replaces any existing entry at the same (extendee, number) or full_name.

Source

pub fn register_text_any(&mut self, entry: TextAnyEntry)

Available on crate feature text only.

Registers a text Any type entry.

Source

pub fn register_text_ext(&mut self, entry: TextExtEntry)

Available on crate feature text only.

Registers a text extension entry.

Source

pub fn json_any_by_url(&self, type_url: &str) -> Option<&JsonAnyEntry>

Available on crate feature json only.

Look up a JSON Any entry by type URL.

Source

pub fn json_ext_by_number( &self, extendee: &str, number: u32, ) -> Option<&JsonExtEntry>

Available on crate feature json only.

Look up a JSON extension entry by (extendee, number).

Source

pub fn json_ext_by_name(&self, full_name: &str) -> Option<&JsonExtEntry>

Available on crate feature json only.

Look up a JSON extension entry by full name.

Source

pub fn text_any_by_url(&self, type_url: &str) -> Option<&TextAnyEntry>

Available on crate feature text only.

Look up a text Any entry by type URL.

Source

pub fn text_ext_by_number( &self, extendee: &str, number: u32, ) -> Option<&TextExtEntry>

Available on crate feature text only.

Look up a text extension entry by (extendee, number).

Source

pub fn text_ext_by_name(&self, full_name: &str) -> Option<&TextExtEntry>

Available on crate feature text only.

Look up a text extension entry by full name.

Trait Implementations§

Source§

impl Debug for TypeRegistry

Source§

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

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

impl Default for TypeRegistry

Source§

fn default() -> TypeRegistry

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