pub struct TypeRegistry { /* private fields */ }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_name → by_number) is preserved.
Implementations§
Source§impl TypeRegistry
impl TypeRegistry
Sourcepub fn register_json_any(&mut self, entry: JsonAnyEntry)
Available on crate feature json only.
pub fn register_json_any(&mut self, entry: JsonAnyEntry)
json only.Registers a JSON Any type entry.
Replaces any existing entry for the same type URL. When the same
message full name is registered under several URLs, a
json_any_by_url lookup of a URL that is not
itself registered uses the most recently registered one.
A lookup by name decodes the payload as this message. A payload under another prefix that does not decode as it fails to serialize as JSON; one that does decode is written with this message’s fields.
Sourcepub fn register_json_ext(&mut self, entry: JsonExtEntry)
Available on crate feature json only.
pub fn register_json_ext(&mut self, entry: JsonExtEntry)
json only.Registers a JSON extension entry. Replaces any existing entry at the
same (extendee, number) or full_name.
Sourcepub fn register_text_any(&mut self, entry: TextAnyEntry)
Available on crate feature text only.
pub fn register_text_any(&mut self, entry: TextAnyEntry)
text only.Registers a text Any type entry.
Replaces any existing entry for the same type URL. When the same
message full name is registered under several URLs, a
text_any_by_url lookup of a URL that is not
itself registered uses the most recently registered one.
A lookup by name decodes the payload as this message. A payload under another prefix that does not decode as it prints with an empty body; one that does decode is written with this message’s fields.
Sourcepub fn register_text_ext(&mut self, entry: TextExtEntry)
Available on crate feature text only.
pub fn register_text_ext(&mut self, entry: TextExtEntry)
text only.Registers a text extension entry. Replaces any existing entry at the
same (extendee, number) or full_name.
Sourcepub fn json_any_by_url(&self, type_url: &str) -> Option<&JsonAnyEntry>
Available on crate feature json only.
pub fn json_any_by_url(&self, type_url: &str) -> Option<&JsonAnyEntry>
json only.Look up a JSON Any entry by type URL.
A registered URL finds its own entry. Any other URL is matched by the
message full name after its last /, and a string without a / as a
bare full name. The entry’s type_url is the registered one, so keep
the URL you looked up as the Any’s type_url.
Sourcepub fn json_ext_by_number(
&self,
extendee: &str,
number: u32,
) -> Option<&JsonExtEntry>
Available on crate feature json only.
pub fn json_ext_by_number( &self, extendee: &str, number: u32, ) -> Option<&JsonExtEntry>
json only.Look up a JSON extension entry by (extendee, number).
Sourcepub fn json_ext_by_name(&self, full_name: &str) -> Option<&JsonExtEntry>
Available on crate feature json only.
pub fn json_ext_by_name(&self, full_name: &str) -> Option<&JsonExtEntry>
json only.Look up a JSON extension entry by full name.
Sourcepub fn text_any_by_url(&self, type_url: &str) -> Option<&TextAnyEntry>
Available on crate feature text only.
pub fn text_any_by_url(&self, type_url: &str) -> Option<&TextAnyEntry>
text only.Look up a text Any entry by type URL.
A registered URL finds its own entry. Any other URL is matched by the
message full name after its last /. A string without a / is found
only by an exact match, unlike in
json_any_by_url. The entry’s type_url is
the registered one, so keep the URL you looked up as the Any’s
type_url.
Sourcepub fn text_ext_by_number(
&self,
extendee: &str,
number: u32,
) -> Option<&TextExtEntry>
Available on crate feature text only.
pub fn text_ext_by_number( &self, extendee: &str, number: u32, ) -> Option<&TextExtEntry>
text only.Look up a text extension entry by (extendee, number).
Sourcepub fn text_ext_by_name(&self, full_name: &str) -> Option<&TextExtEntry>
Available on crate feature text only.
pub fn text_ext_by_name(&self, full_name: &str) -> Option<&TextExtEntry>
text only.Look up a text extension entry by full name.