Struct json_api::query::Sort
[−]
[src]
pub struct Sort { pub direction: Direction, pub field: Path, // some fields omitted }
A single sort instruction containing a direction and field path.
Fields
direction: Direction
The direction to sort by.
field: Path
The name of the field to sort by.
Methods
impl Sort
[src]
fn new(field: Path, direction: Direction) -> Self
[src]
Returns a new Sort
.
fn reverse(&self) -> Self
[src]
Returns a cloned inverse of self
.
Example
use json_api::query::{Direction, Sort}; let chrono = Sort::new("created-at".parse()?, Direction::Asc); let latest = chrono.reverse(); assert_eq!(chrono.field, latest.field); assert_eq!(chrono.direction, Direction::Asc); assert_eq!(latest.direction, Direction::Desc);
Trait Implementations
impl Clone for Sort
[src]
fn clone(&self) -> Sort
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Sort
[src]
impl Eq for Sort
[src]
impl Hash for Sort
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Sort
[src]
fn eq(&self, __arg_0: &Sort) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Sort) -> bool
[src]
This method tests for !=
.
impl Display for Sort
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl FromStr for Sort
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(value: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl Neg for Sort
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
Performs the unary -
operation.
impl<'de> Deserialize<'de> for Sort
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Serialize for Sort
[src]
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
[src]
S: Serializer,
Serialize this value into the given Serde serializer. Read more