pub enum OrderableValue {
Int64(i64),
Float64(OrderedFloat64),
String(ArcStr),
Bool(bool),
Timestamp(Timestamp),
}Expand description
An orderable wrapper around Value for use in B-tree indexes and range queries.
Value itself cannot implement Ord because f64 doesn’t implement Ord
(due to NaN). This wrapper provides total ordering for comparable value types,
enabling use in BTreeMap, BTreeSet, and range queries.
§Supported Types
Int64- standard integer orderingFloat64- total ordering (NaN treated as greater than all other values)String- lexicographic orderingBool- false < trueTimestamp- chronological ordering
Other types (Null, Bytes, List, Map) return None from try_from.
§Examples
use grafeo_common::types::{OrderableValue, Value};
use std::collections::BTreeSet;
let mut set = BTreeSet::new();
set.insert(OrderableValue::try_from(&Value::Int64(30)).unwrap());
set.insert(OrderableValue::try_from(&Value::Int64(10)).unwrap());
set.insert(OrderableValue::try_from(&Value::Int64(20)).unwrap());
// Iterates in sorted order: 10, 20, 30
let values: Vec<_> = set.iter().map(|v| v.as_i64().unwrap()).collect();
assert_eq!(values, vec![10, 20, 30]);Variants§
Int64(i64)
64-bit signed integer
Float64(OrderedFloat64)
64-bit floating point with total ordering (NaN > everything)
String(ArcStr)
UTF-8 string
Bool(bool)
Boolean value (false < true)
Timestamp(Timestamp)
Timestamp (microseconds since epoch)
Implementations§
Source§impl OrderableValue
impl OrderableValue
Trait Implementations§
Source§impl Clone for OrderableValue
impl Clone for OrderableValue
Source§fn clone(&self) -> OrderableValue
fn clone(&self) -> OrderableValue
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 OrderableValue
impl Debug for OrderableValue
Source§impl Hash for OrderableValue
impl Hash for OrderableValue
Source§impl Ord for OrderableValue
impl Ord for OrderableValue
Source§impl PartialEq for OrderableValue
impl PartialEq for OrderableValue
Source§impl PartialOrd for OrderableValue
impl PartialOrd for OrderableValue
impl Eq for OrderableValue
Auto Trait Implementations§
impl Freeze for OrderableValue
impl RefUnwindSafe for OrderableValue
impl Send for OrderableValue
impl Sync for OrderableValue
impl Unpin for OrderableValue
impl UnwindSafe for OrderableValue
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.