Skip to main content

ResourceObject

Trait ResourceObject 

Source
pub trait ResourceObject: Serialize + for<'de> Deserialize<'de> {
    // Required methods
    fn resource_type(&self) -> &str;
    fn resource_id(&self) -> Option<&str>;
    fn field_names() -> &'static [&'static str];

    // Provided methods
    fn resource_lid(&self) -> Option<&str> { ... }
    fn type_info() -> TypeInfo
       where Self: Sized { ... }
}
Expand description

Unifying trait for typed resources and the dynamic Resource fallback.

Required Methods§

Source

fn resource_type(&self) -> &str

The JSON:API type string (e.g. “articles”).

Source

fn resource_id(&self) -> Option<&str>

The server-assigned identifier.

Source

fn field_names() -> &'static [&'static str]

Field names for sparse fieldset support.

Provided Methods§

Source

fn resource_lid(&self) -> Option<&str>

The local identifier (1.1 feature).

Source

fn type_info() -> TypeInfo
where Self: Sized,

Static type metadata for registry and fieldset support.

The default implementation panics. Override this method (or use #[derive(JsonApi)]) to enable TypeRegistry support.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§