[−][src]Trait jsonapi::model::JsonApiModel
A trait for any struct that can be converted from/into a
Resource
. The only requirement is that your
struct has an id: String
field.
You shouldn't be implementing JsonApiModel manually, look at the
jsonapi_model!
macro instead.
Provided methods
fn from_jsonapi_resource(
resource: &Resource,
included: &Option<Resources>
) -> Result<Self>
resource: &Resource,
included: &Option<Resources>
) -> Result<Self>
Create an instance of the struct from a
Resource
fn from_jsonapi_document(doc: &JsonApiDocument) -> Result<Self>
Create a single resource object or collection of resource
objects directly from a
JsonApiDocument
. This method
will parse the document (the data
and included
resources) in an
attempt to instantiate the calling struct.
fn to_jsonapi_resource(&self) -> (Resource, Option<Resources>)
Converts the instance of the struct into a
Resource
fn to_jsonapi_document(&self) -> JsonApiDocument
Converts the struct into a complete
JsonApiDocument