Skip to main content

TypeRegistry

Struct TypeRegistry 

Source
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

Source

pub fn new() -> TypeRegistry

Create an empty type registry.

Source

pub fn register<T>(&mut self) -> &mut TypeRegistry
where T: ResourceObject,

Register a type using its ResourceObject::type_info() implementation.

Source

pub fn register_info(&mut self, info: TypeInfo) -> &mut TypeRegistry

Register a TypeInfo directly.

Source

pub fn get(&self, type_name: &str) -> Option<&TypeInfo>

Look up the TypeInfo for a type name.

Source

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.

Trait Implementations§

Source§

impl Debug for TypeRegistry

Source§

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

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

impl Default for TypeRegistry

Source§

fn default() -> TypeRegistry

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.