pub struct TypeRegistry { /* private fields */ }Expand description
Re-exports of the jsonapi_core types most commonly needed to build
handlers, so handler bodies can import from jsonapi_axum alone.
Deriving JsonApi still requires a direct
jsonapi_core dependency: the derive macro expands to absolute
::jsonapi_core::… paths, so the crate must be nameable in the consumer’s
crate. Only the runtime types are re-exported here.
A registry of static type metadata for include-path validation.
Populated once at application startup via register()
(using derive-generated TypeInfo) or register_info()
(manual). Use validate_include_paths()
to check that include paths are valid relationship traversals.
Implementations§
Source§impl TypeRegistry
impl TypeRegistry
Sourcepub fn new() -> TypeRegistry
pub fn new() -> TypeRegistry
Create an empty type registry.
Sourcepub fn register<T>(&mut self) -> &mut TypeRegistrywhere
T: ResourceObject,
pub fn register<T>(&mut self) -> &mut TypeRegistrywhere
T: ResourceObject,
Register a type using its ResourceObject::type_info() implementation.
Sourcepub fn register_info(&mut self, info: TypeInfo) -> &mut TypeRegistry
pub fn register_info(&mut self, info: TypeInfo) -> &mut TypeRegistry
Register a TypeInfo directly.
Sourcepub fn validate_include_paths(
&self,
root_type: &str,
paths: &[&str],
) -> Result<(), Error>
pub fn validate_include_paths( &self, root_type: &str, paths: &[&str], ) -> Result<(), Error>
Validate include paths against the registered type graph.
Each path is dot-separated (e.g. "comments.author"). Walks hop-by-hop
through relationship targets. Terminal hops don’t require the target type
to be registered.