pub struct ResourceCollection<T: Serialize + Send + Sync + 'static, R: ApiResource<T>> { /* private fields */ }Expand description
A collection of models wrapped for API output.
Laravel-compatible JSON structure:
{ "data": [...], "meta": { "count": ... } }Implementations§
Source§impl<T: Serialize + Send + Sync + 'static, R: ApiResource<T>> ResourceCollection<T, R>
impl<T: Serialize + Send + Sync + 'static, R: ApiResource<T>> ResourceCollection<T, R>
Sourcepub fn to_array(&self) -> Value
pub fn to_array(&self) -> Value
Return the API representation as a JSON Value.
Includes data and meta (count) keys.
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Return the API representation as a pretty-printed JSON string.
Sourcepub fn with_meta(self, extra: HashMap<String, Value>) -> Value
pub fn with_meta(self, extra: HashMap<String, Value>) -> Value
Add additional meta keys to the response.
Sourcepub fn into_inner(self) -> Vec<T>
pub fn into_inner(self) -> Vec<T>
Consume the collection and return the inner models.
Auto Trait Implementations§
impl<T, R> Freeze for ResourceCollection<T, R>
impl<T, R> RefUnwindSafe for ResourceCollection<T, R>
impl<T, R> Send for ResourceCollection<T, R>
impl<T, R> Sync for ResourceCollection<T, R>
impl<T, R> Unpin for ResourceCollection<T, R>
impl<T, R> UnsafeUnpin for ResourceCollection<T, R>
impl<T, R> UnwindSafe for ResourceCollection<T, R>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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