pub struct QueryOptions {
pub sort: Vec<(String, SortDir)>,
pub limit: Option<usize>,
pub offset: usize,
}Expand description
Decoded query options.
Sort is an ordered list of (field, dir) pairs; the wire encodes it as a
JSON array so key/priority order is preserved (a JSON object would lose
order through serde_json’s map decode).
Fields§
§sort: Vec<(String, SortDir)>§limit: Option<usize>§offset: usizeImplementations§
Source§impl QueryOptions
impl QueryOptions
Sourcepub fn parse(options_json: Option<&str>) -> Result<Self, NookError>
pub fn parse(options_json: Option<&str>) -> Result<Self, NookError>
Parses an optional wire optionsJson. None/empty → default.
§Errors
Returns NookError::InvalidArg if the JSON is malformed or a value
is out of range (negative / fractional limit/offset, bad dir).
Sourcepub fn validate_sort_fields<'f>(
&self,
field_ty: impl Fn(&str) -> Option<&'f FieldType>,
) -> Result<(), NookError>
pub fn validate_sort_fields<'f>( &self, field_ty: impl Fn(&str) -> Option<&'f FieldType>, ) -> Result<(), NookError>
Validates that every sort field exists and is orderable (not an
array). Callers that sort (apply) AND callers that ignore sort but
must reject an invalid spec (count) both run this, so the
accept/reject decision is identical across read ops.
§Errors
NookError::Schema if a sort field is unknown or non-orderable.
Sourcepub fn apply<'f>(
&self,
docs: Vec<Value>,
id_field: &str,
field_ty: impl Fn(&str) -> Option<&'f FieldType>,
) -> Result<Vec<Value>, NookError>
pub fn apply<'f>( &self, docs: Vec<Value>, id_field: &str, field_ty: impl Fn(&str) -> Option<&'f FieldType>, ) -> Result<Vec<Value>, NookError>
Orders docs in place by the configured sort keys, then applies
offset/limit. Comparison is schema-typed via field_ty
(a lookup field name → Option<&FieldType>). null/missing values
sort LAST regardless of direction; ties break by id_field (ascending)
for deterministic pagination.
§Errors
NookError::Schema if a sort field is unknown or its type is not
orderable (array).
Trait Implementations§
Source§impl Clone for QueryOptions
impl Clone for QueryOptions
Source§fn clone(&self) -> QueryOptions
fn clone(&self) -> QueryOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more