Skip to main content

ValueType

Enum ValueType 

Source
pub enum ValueType {
Show 15 variants Text, Long, Float, Date, Bool, SmallInt, Int32, Decimal, Time, Timestamp, Uuid, Bytes, Json, Array(Box<ValueType>), Ref(TypeName),
}
Expand description

Declared value type of a property.

The names accepted on the wire are wider than the variants (see ValueType::from_object_type_name); the variants are the canonical set.

Variants§

§

Text

Free-form text.

§

Long

64-bit integer (SQL BIGINT). Wire names “Integer”/“Long” keep mapping here for backward compatibility with existing schemas.

§

Float

64-bit float (SQL DOUBLE PRECISION / FLOAT8).

§

Date

Calendar date (SQL DATE). Values validate + normalize to YYYY-MM-DD; invalid input coerces to Null.

§

Bool

Boolean.

§

SmallInt

SQL SMALLINT: range-checked to i16 on ingress, stored as Long.

§

Int32

SQL INT/INTEGER (32-bit): range-checked to i32, stored as Long. Wire name “Int32”/“Int” (plain “Integer” stays Long, see above).

§

Decimal

SQL DECIMAL/NUMERIC. Values coerce to crate::Decimal — i128 unscaled digits plus a scale, exact, never f64.

UNPARAMETERIZED, deliberately. The declared (precision, scale) stays in the source-schema mapping rather than here, because the value already carries its own exact scale and reports its own precision, which is enough for storage, comparison and round-tripping. Adding them here would change the serde shape of this variant from the string "Decimal" to a struct, and every stored schema record and .ant schema_type payload is written in the current shape.

REVISIT WHEN: the SQL auto-mapper needs to VALIDATE values against declared column types — rejecting a scale-6 value written into a DECIMAL(10,4) column, rather than storing it at whatever scale it arrived with. That check cannot be made from the value alone; it needs the declaration, and at that point the declaration has to live here. Doing it will need a backward-compatible deserializer that still accepts the bare "Decimal" string.

§

Time

SQL TIME: normalized HH:MM:SS.ffffff (fixed 6-digit fraction so lexicographic order == chronological order).

§

Timestamp

SQL TIMESTAMP/TIMESTAMPTZ: normalized UTC RFC3339 with fixed 6-digit fraction (YYYY-MM-DDTHH:MM:SS.ffffffZ) so lexicographic order == chronological order. Offset-less input is taken as UTC.

§

Uuid

UUID/UNIQUEIDENTIFIER: validated 8-4-4-4-12 hex, lowercased.

§

Bytes

BLOB/BYTEA/VARBINARY: base64 text, charset/padding validated.

§

Json

JSON/JSONB, document-store subdocuments: stored as real JSON (PropertyValue::Json), not stringified.

§

Array(Box<ValueType>)

Typed array (Postgres arrays, document-store arrays): every element coerced against the inner type; stored as a JSON array.

§

Ref(TypeName)

Reference to another declared type by name.

Implementations§

Source§

impl ValueType

Source

pub fn from_object_type_name(name: &str) -> Self

Parse an OpenSPG basic-type name (e.g. “Text”, “Integer”, “Float”) or a user-defined type reference.

Trait Implementations§

Source§

impl Clone for ValueType

Source§

fn clone(&self) -> ValueType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ValueType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ValueType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ValueType

Source§

impl PartialEq for ValueType

Source§

fn eq(&self, other: &ValueType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ValueType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ValueType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.