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§
Sourcefn resource_type(&self) -> &str
fn resource_type(&self) -> &str
The JSON:API type string (e.g. “articles”).
Sourcefn resource_id(&self) -> Option<&str>
fn resource_id(&self) -> Option<&str>
The server-assigned identifier.
Sourcefn field_names() -> &'static [&'static str]
fn field_names() -> &'static [&'static str]
Field names for sparse fieldset support.
Provided Methods§
Sourcefn resource_lid(&self) -> Option<&str>
fn resource_lid(&self) -> Option<&str>
The local identifier (1.1 feature).
Sourcefn type_info() -> TypeInfowhere
Self: Sized,
fn type_info() -> TypeInfowhere
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".