#[non_exhaustive]pub enum ValueFilter<'a> {
Range {
field: &'a [u8],
min: &'a [u8],
max: &'a [u8],
},
Eq {
field: &'a [u8],
value: &'a [u8],
},
}Expand description
One FILTER predicate: which stored value field it reads, and the
test on it — the wire’s RANGE / EQ shapes, in-process.
The bounds are raw bytes and are coerced with the type the field was DECLARED as, so a numeric range compares numerically rather than lexicographically.
use kevy_embedded::ValueFilter;
let cheap = ValueFilter::Range { field: b"price", min: b"0", max: b"10" };
assert_ne!(cheap, ValueFilter::Eq { field: b"price", value: b"5" });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Range
field between min and max, both inclusive.
// u:1 (age 30, paid, total 5), u:2 (40, paid, 20), u:3 (50, due, 8)
let f = [ValueFilter::Range { field: b"total", min: b"5", max: b"10" }];
assert_eq!(keys(ScalarQueryOpts::default().with_filters(&f))?, [b"u:1".to_vec(), b"u:3".to_vec()]);Fields
§
field: &'a [u8]The declared value field to read.
// u:1 (age 30, paid, total 5), u:2 (40, paid, 20), u:3 (50, due, 8)
// `total` is declared I64, so the bounds compare as numbers, not bytes
let f = [ValueFilter::Range { field: b"total", min: b"9", max: b"100" }];
assert_eq!(keys(ScalarQueryOpts::default().with_filters(&f))?, [b"u:2".to_vec()]);Eq
field exactly value.
// u:1 (age 30, paid, total 5), u:2 (40, paid, 20), u:3 (50, due, 8)
let f = [ValueFilter::Eq { field: b"status", value: b"due" }];
assert_eq!(keys(ScalarQueryOpts::default().with_filters(&f))?, [b"u:3".to_vec()]);Fields
§
field: &'a [u8]The declared value field to read.
// u:1 (age 30, paid, total 5), u:2 (40, paid, 20), u:3 (50, due, 8)
// a field the index does not store is refused, not read as empty
let f = [ValueFilter::Eq { field: b"email", value: b"x" }];
assert!(keys(ScalarQueryOpts::default().with_filters(&f)).is_err());Trait Implementations§
Source§impl<'a> Clone for ValueFilter<'a>
impl<'a> Clone for ValueFilter<'a>
impl<'a> Copy for ValueFilter<'a>
Source§impl<'a> Debug for ValueFilter<'a>
impl<'a> Debug for ValueFilter<'a>
impl<'a> Eq for ValueFilter<'a>
Source§impl<'a> Hash for ValueFilter<'a>
impl<'a> Hash for ValueFilter<'a>
Source§impl<'a> PartialEq for ValueFilter<'a>
impl<'a> PartialEq for ValueFilter<'a>
impl<'a> StructuralPartialEq for ValueFilter<'a>
Auto Trait Implementations§
impl<'a> Freeze for ValueFilter<'a>
impl<'a> RefUnwindSafe for ValueFilter<'a>
impl<'a> Send for ValueFilter<'a>
impl<'a> Sync for ValueFilter<'a>
impl<'a> Unpin for ValueFilter<'a>
impl<'a> UnsafeUnpin for ValueFilter<'a>
impl<'a> UnwindSafe for ValueFilter<'a>
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