Skip to main content

TableRegistry

Struct TableRegistry 

Source
pub struct TableRegistry { /* private fields */ }
Expand description

Runtime-configurable table registry.

By default the registry has no custom parsers. Use register to add one.

§Precedence (per table_id)

  1. Custom-registered parser (table_id in the custom map) → crate::tables::AnyTableSection::Other
  2. Built-in dispatch (crate::tables::AnyTableSection::parse) → typed variant
  3. Unknown → crate::tables::AnyTableSection::Unknown

Implementations§

Source§

impl TableRegistry

Source

pub fn new() -> Self

Create an empty registry (built-in dispatch only).

Source

pub fn register<T>(&mut self) -> &mut Self
where T: for<'a> TableDef<'a> + TableObject + 'static,

Register an owned custom table-section type for every table_id in its TableDef::TABLE_ID_RANGES.

§Owned types only

T must be 'static — no borrowed slices. The registered value is type-erased as Box<dyn TableObject>; dyn Any downcast requires the concrete type to be 'static.

§Multi-range registration

A type may cover multiple table_id ranges (e.g. &[(0x90, 0x90), (0x92, 0x93)]). Every table_id in every range is registered under the same parse closure.

Registering a type whose table_id is already used by a built-in overrides the built-in for that table_id.

Re-registering the same table_id replaces the prior custom parser (last wins). A failing custom parse surfaces the client’s Parse::Error unwrapped — embed identifying context (type/table_id) in your error’s what/reason fields.

Trait Implementations§

Source§

impl Default for TableRegistry

Source§

fn default() -> TableRegistry

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> ErasedDestructor for T
where T: 'static,

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.