pub struct Document {
pub data: Option<PrimaryData>,
pub errors: Option<Vec<ErrorObject>>,
pub included: Option<Vec<ResourceObject>>,
pub links: Option<Links>,
pub meta: Option<BTreeMap<String, Value>>,
}Expand description
A JSON:API top-level document.
Exactly one of data or errors is present in a valid document; the
constructors below are the supported way to build one.
Fields§
§data: Option<PrimaryData>§errors: Option<Vec<ErrorObject>>§included: Option<Vec<ResourceObject>>Compound-document sidecar, populated by ?include=.
links: Option<Links>§meta: Option<BTreeMap<String, Value>>Implementations§
Source§impl Document
impl Document
Sourcepub fn single(resource: ResourceObject) -> Self
pub fn single(resource: ResourceObject) -> Self
A document whose primary data is a single resource.
Sourcepub fn collection(resources: Vec<ResourceObject>) -> Self
pub fn collection(resources: Vec<ResourceObject>) -> Self
A document whose primary data is a collection — a listing response.
Sourcepub fn errors(errors: Vec<ErrorObject>) -> Self
pub fn errors(errors: Vec<ErrorObject>) -> Self
An error document. JSON:API allows several errors per response.
Sourcepub fn with_links(self, links: Links) -> Self
pub fn with_links(self, links: Links) -> Self
Attach top-level links — pagination links on a listing, for instance.
Sourcepub fn with_included(self, included: Vec<ResourceObject>) -> Self
pub fn with_included(self, included: Vec<ResourceObject>) -> Self
Attach compound-document resources, as requested by ?include=.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Document
impl<'de> Deserialize<'de> for Document
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Document
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnsafeUnpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more