pub enum MetadataValue {
String(String),
Integer(i64),
Float(f64),
Boolean(bool),
StringArray(Vec<String>),
}Expand description
Supported metadata value types.
EdgeVec metadata supports 5 value types optimized for common RAG and vector search use cases.
§Type Mapping
| Rust Type | JSON Type | TypeScript Type |
|---|---|---|
| String | string | string |
| Integer | number | number |
| Float | number | number |
| Boolean | boolean | boolean |
| StringArray | string[] | string[] |
§Serialization
Uses adjacently-tagged representation for unambiguous type preservation:
use edgevec::metadata::MetadataValue;
let value = MetadataValue::Integer(42);
let json = serde_json::to_string(&value).unwrap();
assert_eq!(json, r#"{"type":"integer","value":42}"#);§Example
use edgevec::metadata::MetadataValue;
let title = MetadataValue::String("Document Title".to_string());
let page_count = MetadataValue::Integer(42);
let relevance = MetadataValue::Float(0.95);
let is_verified = MetadataValue::Boolean(true);
let tags = MetadataValue::StringArray(vec!["rust".to_string(), "wasm".to_string()]);
// Type checking
assert!(title.is_string());
assert!(page_count.is_integer());
assert!(relevance.is_float());
assert!(is_verified.is_boolean());
assert!(tags.is_string_array());
// Value extraction
assert_eq!(title.as_string(), Some("Document Title"));
assert_eq!(page_count.as_integer(), Some(42));Variants§
String(String)
UTF-8 string value (max 65,536 bytes).
Use for titles, descriptions, content, and any text data.
Integer(i64)
64-bit signed integer.
Use for counts, IDs, timestamps (Unix epoch), and numeric identifiers.
Float(f64)
64-bit IEEE 754 floating point.
Use for scores, weights, probabilities, and continuous values. Note: NaN and Infinity are rejected during validation.
Boolean(bool)
Boolean true/false.
Use for flags, binary filters, and on/off states.
StringArray(Vec<String>)
Array of UTF-8 strings (max 1,024 elements).
Use for tags, categories, labels, and multi-value fields.
Implementations§
Source§impl MetadataValue
impl MetadataValue
Sourcepub fn type_name(&self) -> &'static str
pub fn type_name(&self) -> &'static str
Returns the type name as a static string.
This matches the JSON serialization type field.
§Example
use edgevec::metadata::MetadataValue;
assert_eq!(MetadataValue::String("hi".into()).type_name(), "string");
assert_eq!(MetadataValue::Integer(42).type_name(), "integer");
assert_eq!(MetadataValue::Float(2.5).type_name(), "float");
assert_eq!(MetadataValue::Boolean(true).type_name(), "boolean");
assert_eq!(MetadataValue::StringArray(vec![]).type_name(), "string_array");Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if this value is an Integer type.
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Returns true if this value is a Boolean type.
Sourcepub fn is_string_array(&self) -> bool
pub fn is_string_array(&self) -> bool
Returns true if this value is a StringArray type.
Sourcepub fn as_string(&self) -> Option<&str>
pub fn as_string(&self) -> Option<&str>
Attempts to extract the String value.
Returns None if this is not a String variant.
§Example
use edgevec::metadata::MetadataValue;
let value = MetadataValue::String("hello".to_string());
assert_eq!(value.as_string(), Some("hello"));
let value = MetadataValue::Integer(42);
assert_eq!(value.as_string(), None);Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Attempts to extract the Integer value.
Returns None if this is not an Integer variant.
§Example
use edgevec::metadata::MetadataValue;
let value = MetadataValue::Integer(42);
assert_eq!(value.as_integer(), Some(42));
let value = MetadataValue::Float(2.5);
assert_eq!(value.as_integer(), None);Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
Attempts to extract the Float value.
Returns None if this is not a Float variant.
§Example
use edgevec::metadata::MetadataValue;
let value = MetadataValue::Float(2.5);
assert_eq!(value.as_float(), Some(2.5));
let value = MetadataValue::Integer(42);
assert_eq!(value.as_float(), None);Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Attempts to extract the Boolean value.
Returns None if this is not a Boolean variant.
§Example
use edgevec::metadata::MetadataValue;
let value = MetadataValue::Boolean(true);
assert_eq!(value.as_boolean(), Some(true));
let value = MetadataValue::Integer(1);
assert_eq!(value.as_boolean(), None);Sourcepub fn as_string_array(&self) -> Option<&[String]>
pub fn as_string_array(&self) -> Option<&[String]>
Attempts to extract the StringArray value.
Returns None if this is not a StringArray variant.
§Example
use edgevec::metadata::MetadataValue;
let value = MetadataValue::StringArray(vec!["a".into(), "b".into()]);
assert_eq!(value.as_string_array(), Some(&["a".to_string(), "b".to_string()][..]));
let value = MetadataValue::String("not an array".to_string());
assert_eq!(value.as_string_array(), None);Trait Implementations§
Source§impl Clone for MetadataValue
impl Clone for MetadataValue
Source§fn clone(&self) -> MetadataValue
fn clone(&self) -> MetadataValue
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MetadataValue
impl Debug for MetadataValue
Source§impl<'de> Deserialize<'de> for MetadataValue
impl<'de> Deserialize<'de> for MetadataValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for MetadataValue
impl Display for MetadataValue
Source§impl From<&str> for MetadataValue
impl From<&str> for MetadataValue
Source§impl From<String> for MetadataValue
impl From<String> for MetadataValue
Source§impl From<bool> for MetadataValue
impl From<bool> for MetadataValue
Source§impl From<f32> for MetadataValue
impl From<f32> for MetadataValue
Source§impl From<f64> for MetadataValue
impl From<f64> for MetadataValue
Source§impl From<i32> for MetadataValue
impl From<i32> for MetadataValue
Source§impl From<i64> for MetadataValue
impl From<i64> for MetadataValue
Source§impl PartialEq for MetadataValue
impl PartialEq for MetadataValue
Source§impl Serialize for MetadataValue
impl Serialize for MetadataValue
impl StructuralPartialEq for MetadataValue
Auto Trait Implementations§
impl Freeze for MetadataValue
impl RefUnwindSafe for MetadataValue
impl Send for MetadataValue
impl Sync for MetadataValue
impl Unpin for MetadataValue
impl UnwindSafe for MetadataValue
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.