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)
- Custom-registered parser (table_id in the
custommap) →crate::tables::AnyTableSection::Other - Built-in dispatch (
crate::tables::AnyTableSection::parse) → typed variant - Unknown →
crate::tables::AnyTableSection::Unknown
Implementations§
Source§impl TableRegistry
impl TableRegistry
Sourcepub fn register<T>(&mut self) -> &mut Selfwhere
T: for<'a> TableDef<'a> + TableObject + 'static,
pub fn register<T>(&mut self) -> &mut Selfwhere
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.