#[non_exhaustive]pub enum IndexValType {
Vector,
I64,
F64,
Str,
}Expand description
Declared scalar type of an index (TYPE i64|f64|str).
use kevy_index::ValType;
assert_eq!(ValType::parse(b"F64"), Some(ValType::F64));
assert_eq!(ValType::parse(ValType::Str.tag().as_bytes()), Some(ValType::Str));
assert_eq!(ValType::parse(b"u8"), None);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.
Vector
f32 LE vector blob (ANN kinds parse the field themselves — never coerced through IndexValue).
use kevy_index::{AnnSpec, IndexKind, IndexSpec, IndexValue, ValType};
let knn = IndexSpec::builder("emb", "doc:", IndexKind::Ann, ValType::Vector)
.with_field("emb")
.with_ann(AnnSpec::new(3))
.build()?;
assert_eq!(knn.ty(), ValType::Vector);
assert_eq!(IndexValue::coerce(ValType::Vector, b"\0\0\0\0"), None, "never a scalar");I64
Signed 64-bit integer.
use kevy_index::{IndexValue, ValType};
assert_eq!(IndexValue::coerce(ValType::I64, b"-7"), Some(IndexValue::I64(-7)));
assert_eq!(IndexValue::coerce(ValType::I64, b"7.5"), None);F64
Finite 64-bit float (NaN coerce-fails).
use kevy_index::{IndexValue, ValType};
assert_eq!(IndexValue::coerce(ValType::F64, b"7.5"), Some(IndexValue::F64(7.5)));
assert_eq!(IndexValue::coerce(ValType::F64, b"nan"), None);Str
Raw bytes, memcmp order.
use kevy_index::{IndexValue, ValType};
let (a, b) = (IndexValue::coerce(ValType::Str, b"B"), IndexValue::coerce(ValType::Str, b"a"));
assert!(a < b, "bytewise: 'B' (0x42) sorts before 'a' (0x61)");Implementations§
Trait Implementations§
impl Copy for ValType
impl Eq for ValType
impl StructuralPartialEq for ValType
Auto Trait Implementations§
impl Freeze for ValType
impl RefUnwindSafe for ValType
impl Send for ValType
impl Sync for ValType
impl Unpin for ValType
impl UnsafeUnpin for ValType
impl UnwindSafe for ValType
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