use crate::clock::ClockTime;
use crate::symbol::SymbolId;
#[derive(Clone, Debug, PartialEq)]
pub enum Value {
Symbol(SymbolId),
Integer(i64),
Float(f64),
Boolean(bool),
String(String),
Timestamp(ClockTime),
}
impl Value {
#[must_use]
pub(crate) fn index_key_bytes(&self) -> Vec<u8> {
let mut out = Vec::new();
crate::canonical::encode_value(self, &mut out);
out
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn value_variants_compare_by_content() {
assert_eq!(Value::Integer(5), Value::Integer(5));
assert_ne!(Value::Integer(5), Value::Integer(6));
assert_ne!(Value::Integer(5), Value::Boolean(false));
}
#[test]
fn float_value_preserves_precision() {
let a = Value::Float(1.25);
let b = Value::Float(1.25);
assert_eq!(a, b);
}
}