Skip to main content

velr_types/
property.rs

1use crate::list::ListValue;
2use crate::spatial::{GeographyValue, GeometryValue, PointValue};
3use crate::temporal::{
4    DateValue, DurationValue, LocalDateTimeValue, LocalTimeValue, ZonedDateTimeValue,
5    ZonedTimeValue,
6};
7use crate::vector::VectorValue;
8
9#[derive(Debug, Clone, PartialEq)]
10pub enum PropertyValue {
11    Null,
12    Bool(bool),
13    Integer(i64),
14    Float(f64),
15    String(String),
16
17    Date(DateValue),
18    LocalTime(LocalTimeValue),
19    ZonedTime(ZonedTimeValue),
20    LocalDateTime(LocalDateTimeValue),
21    ZonedDateTime(ZonedDateTimeValue),
22    Duration(DurationValue),
23
24    Point(PointValue),
25    Geometry(GeometryValue),
26    Geography(GeographyValue),
27
28    List(ListValue),
29    Vector(VectorValue),
30    Bytes(Vec<u8>),
31}
32
33#[derive(Debug, Copy, Clone, PartialEq)]
34pub enum PropertyValueRef<'a> {
35    Null,
36    Bool(bool),
37    Integer(i64),
38    Float(f64),
39    String(&'a str),
40
41    Date(&'a DateValue),
42    LocalTime(&'a LocalTimeValue),
43    ZonedTime(&'a ZonedTimeValue),
44    LocalDateTime(&'a LocalDateTimeValue),
45    ZonedDateTime(&'a ZonedDateTimeValue),
46    Duration(&'a DurationValue),
47
48    Point(&'a PointValue),
49    Geometry(&'a GeometryValue),
50    Geography(&'a GeographyValue),
51
52    List(&'a ListValue),
53    Vector(&'a VectorValue),
54    Bytes(&'a [u8]),
55}
56
57impl PropertyValue {
58    pub fn as_ref(&self) -> PropertyValueRef<'_> {
59        match self {
60            Self::Null => PropertyValueRef::Null,
61            Self::Bool(v) => PropertyValueRef::Bool(*v),
62            Self::Integer(v) => PropertyValueRef::Integer(*v),
63            Self::Float(v) => PropertyValueRef::Float(*v),
64            Self::String(v) => PropertyValueRef::String(v),
65            Self::Date(v) => PropertyValueRef::Date(v),
66            Self::LocalTime(v) => PropertyValueRef::LocalTime(v),
67            Self::ZonedTime(v) => PropertyValueRef::ZonedTime(v),
68            Self::LocalDateTime(v) => PropertyValueRef::LocalDateTime(v),
69            Self::ZonedDateTime(v) => PropertyValueRef::ZonedDateTime(v),
70            Self::Duration(v) => PropertyValueRef::Duration(v),
71            Self::Point(v) => PropertyValueRef::Point(v),
72            Self::Geometry(v) => PropertyValueRef::Geometry(v),
73            Self::Geography(v) => PropertyValueRef::Geography(v),
74            Self::List(v) => PropertyValueRef::List(v),
75            Self::Vector(v) => PropertyValueRef::Vector(v),
76            Self::Bytes(v) => PropertyValueRef::Bytes(v),
77        }
78    }
79}