pub struct SortParams {
pub sort_by: String,
pub direction: SortDirection,
}Expand description
Query parameters for sorting a collection endpoint.
{"sort_by": "created_at", "direction": "desc"}Fields§
§sort_by: StringThe field name to sort by (e.g. "created_at", "name").
direction: SortDirectionSort direction. Defaults to SortDirection::Asc.
Implementations§
Source§impl SortParams
impl SortParams
Sourcepub fn new(sort_by: impl Into<String>, direction: SortDirection) -> Self
pub fn new(sort_by: impl Into<String>, direction: SortDirection) -> Self
Create sort params with the given field and direction.
§Examples
use api_bones::query::{SortParams, SortDirection};
let p = SortParams::new("created_at", SortDirection::Desc);
assert_eq!(p.sort_by, "created_at");
assert_eq!(p.direction, SortDirection::Desc);Trait Implementations§
Source§impl Clone for SortParams
impl Clone for SortParams
Source§fn clone(&self) -> SortParams
fn clone(&self) -> SortParams
Returns a duplicate of the value. Read more
1.0.0 · 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 SortParams
impl Debug for SortParams
Source§impl<'de> Deserialize<'de> for SortParams
impl<'de> Deserialize<'de> for SortParams
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
Source§impl PartialEq for SortParams
impl PartialEq for SortParams
Source§impl Serialize for SortParams
impl Serialize for SortParams
impl Eq for SortParams
impl StructuralPartialEq for SortParams
Auto Trait Implementations§
impl Freeze for SortParams
impl RefUnwindSafe for SortParams
impl Send for SortParams
impl Sync for SortParams
impl Unpin for SortParams
impl UnsafeUnpin for SortParams
impl UnwindSafe for SortParams
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