pub struct JsonApiQuery { /* private fields */ }Expand description
Parsed JSON:API query string context — the Rust equivalent of Laravel’s
automatic handling of ?include= and ?fields[type]= parameters.
Parse it from a request’s query string and pass it to a
JsonApiItem / JsonApiCollection via JsonApiItem::with_query:
let query = JsonApiQuery::parse(uri.query().unwrap_or(""));
PostResource::make(post).with_query(&query).include("author", ...)The default (or JsonApiQuery::ignored) query performs no filtering and
no relationship inclusion — the equivalent of Laravel’s
ignoreFieldsAndIncludesInQueryString().
Implementations§
Source§impl JsonApiQuery
impl JsonApiQuery
Sourcepub fn parse(raw: &str) -> Self
pub fn parse(raw: &str) -> Self
Parse include / fields[type] parameters from a raw query string.
Example: include=author,comments&fields[posts]=title,created_at.
Sourcepub fn ignored() -> Self
pub fn ignored() -> Self
A query that ignores the query string entirely — full attributes,
no relationship inclusion (Laravel’s ignoreFieldsAndIncludesInQueryString).
Sourcepub fn includes(&self, path: &str) -> bool
pub fn includes(&self, path: &str) -> bool
Whether the given relationship path was requested via include=.
Nested paths imply their ancestors: requesting author.posts also
includes author.
Sourcepub fn fieldset(&self, type_: &str) -> Option<&HashSet<String>>
pub fn fieldset(&self, type_: &str) -> Option<&HashSet<String>>
The sparse fieldset requested for a resource type, if any.
Sourcepub fn filter_attributes(&self, type_: &str, attributes: Value) -> Value
pub fn filter_attributes(&self, type_: &str, attributes: Value) -> Value
Filter an attributes object by the sparse fieldset for type_.
Per the JSON:API spec this only ever filters attributes, never
relationships.
Sourcepub fn has_includes(&self) -> bool
pub fn has_includes(&self) -> bool
Whether any include requests are present.
Trait Implementations§
Source§impl Clone for JsonApiQuery
impl Clone for JsonApiQuery
Source§impl Debug for JsonApiQuery
impl Debug for JsonApiQuery
Auto Trait Implementations§
impl Freeze for JsonApiQuery
impl RefUnwindSafe for JsonApiQuery
impl Send for JsonApiQuery
impl Sync for JsonApiQuery
impl Unpin for JsonApiQuery
impl UnsafeUnpin for JsonApiQuery
impl UnwindSafe for JsonApiQuery
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Event for T
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more