pub struct TagRegistry {
entries: HashMap<&'static str, Entry>,
}Expand description
A registry of types participating in tagged-map serialization.
Fields§
§entries: HashMap<&'static str, Entry>Implementations§
Source§impl TagRegistry
impl TagRegistry
Sourcepub fn from_type<T: ?Sized + MsgpackTagged>() -> Self
pub fn from_type<T: ?Sized + MsgpackTagged>() -> Self
Construct a registry by starting the type-graph walk at T. Calls
T::register_into against a fresh registry, which registers T
itself and then recurses through every reachable tagged field/variant
type. The standard one-shot way to build a registry for a top-level
value about to be encoded.
let registry = TagRegistry::from_type::<Program>();Sourcepub fn contains(&self, name: &str) -> bool
pub fn contains(&self, name: &str) -> bool
Whether name corresponds to a registered serde name. Used by
crate::Serializer::with_strategy to fail fast when a strategy
override targets a name the registry never saw — almost always a
type-graph miss bug. Pair with type_name_basename when starting
from a Rust type:
registry.contains(type_name_basename::<Circuit<F>>())Sourcepub fn try_insert<T: MsgpackTagged>(&mut self, name: &'static str) -> bool
pub fn try_insert<T: MsgpackTagged>(&mut self, name: &'static str) -> bool
Register a type under its serde name.
Returns true if this type was newly inserted — the caller (typically a
macro-generated register_into body) should then recurse into the type’s
field types. Returns false if the same type was already registered,
short-circuiting the recursive walk.
Panics if a different Rust type is already registered under the same
name — that signals a real serde-name collision, which the user must
resolve with #[serde(rename = "...")] on one of the types.
Sourcepub fn get(&self, name: &str) -> Option<&Entry>
pub fn get(&self, name: &str) -> Option<&Entry>
Look up a type’s entry by serde name. Returns None if the type was
never registered — the wrapper decides whether that’s an error
(encode-side) or a clean failure to decode (decode-side).