pub struct ResourceResponse { /* private fields */ }Expand description
A resource on its way out: the data, whatever travels beside it, and the status it goes with.
Implementations§
Source§impl ResourceResponse
impl ResourceResponse
pub fn new(data: Json, wrap: Option<&'static str>) -> Self
Sourcepub fn additional(self, key: &str, value: impl Into<Json>) -> Self
pub fn additional(self, key: &str, value: impl Into<Json>) -> Self
Add a top-level key beside the data.
Sourcepub fn path(self, path: &str) -> Self
pub fn path(self, path: &str) -> Self
The path the pagination links are built on. Without it they are
relative — ?page=2 — which every client resolves correctly against
the URL it just requested.
Sourcepub fn paginate(self, current_page: i64, per_page: i64, total: i64) -> Self
pub fn paginate(self, current_page: i64, per_page: i64, total: i64) -> Self
Describe page-number pagination, with Laravel’s meta and links.
Three numbers rather than a Page, so this crate does not have to know
about the database — and so it works for a page that came from
anywhere else.
Sourcepub fn cursor(self, next_cursor: Option<String>, per_page: i64) -> Self
pub fn cursor(self, next_cursor: Option<String>, per_page: i64) -> Self
Describe cursor pagination: a next_cursor that is null at the end.
pub fn with_status(self, status: impl Into<Status>) -> Self
pub fn with_header(self, name: &str, value: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for ResourceResponse
impl Clone for ResourceResponse
Source§fn clone(&self) -> ResourceResponse
fn clone(&self) -> ResourceResponse
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceResponse
impl Debug for ResourceResponse
Source§impl IntoResponse for ResourceResponse
impl IntoResponse for ResourceResponse
fn into_response(self) -> Response
Auto Trait Implementations§
impl Freeze for ResourceResponse
impl RefUnwindSafe for ResourceResponse
impl Send for ResourceResponse
impl Sync for ResourceResponse
impl Unpin for ResourceResponse
impl UnsafeUnpin for ResourceResponse
impl UnwindSafe for ResourceResponse
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