Struct TagRegistry

Source
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

Source

pub fn new() -> Self

Construct an empty registry.

Source

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>();
Source

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>>())
Source

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.

Source

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

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Debug for TagRegistry

Source§

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

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

impl Default for TagRegistry

Source§

fn default() -> TagRegistry

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.