Skip to main content

TypedValue

Enum TypedValue 

Source
pub enum TypedValue {
    Ref(i64),
    Boolean(bool),
    Long(i64),
    Double(OrderedFloat<f64>),
    Instant(DateTime<Utc>),
    String(Arc<String>),
    Keyword(Arc<Keyword>),
    Uuid(Uuid),
    Bytes(Bytes),
}
Expand description

Represents a value that can be stored in a Mentat store.

Variants§

§

Ref(i64)

§

Boolean(bool)

§

Long(i64)

§

Double(OrderedFloat<f64>)

§

Instant(DateTime<Utc>)

§

String(Arc<String>)

§

Keyword(Arc<Keyword>)

§

Uuid(Uuid)

§

Bytes(Bytes)

Implementations§

Source§

impl TypedValue

Source

pub fn is_congruent_with<T>(&self, t: T) -> bool
where T: Into<Option<ValueType>>,

Returns true if the provided type is Some and matches this value’s type, or if the provided type is None.

Source

pub fn matches_type(&self, t: ValueType) -> bool

Source

pub fn value_type(&self) -> ValueType

Source

pub fn typed_ns_keyword<S, T>(ns: S, name: T) -> TypedValue
where S: AsRef<str>, T: AsRef<str>,

Construct a new TypedValue::Keyword instance by cloning the provided values and wrapping them in a new ValueRc. This is expensive, so this might be best limited to tests.

Source

pub fn typed_string<S>(s: S) -> TypedValue
where S: AsRef<str>,

Construct a new TypedValue::String instance by cloning the provided value and wrapping it in a new ValueRc. This is expensive, so this might be best limited to tests.

Source

pub fn current_instant() -> TypedValue

Source

pub fn instant(micros: i64) -> TypedValue

Construct a new TypedValue::Instant instance from the provided microsecond timestamp.

Source

pub fn into_known_entid(self) -> Option<KnownEntid>

Source

pub fn into_entid(self) -> Option<i64>

Source

pub fn into_kw(self) -> Option<Arc<Keyword>>

Source

pub fn into_boolean(self) -> Option<bool>

Source

pub fn into_long(self) -> Option<i64>

Source

pub fn into_double(self) -> Option<f64>

Source

pub fn into_instant(self) -> Option<DateTime<Utc>>

Source

pub fn into_timestamp(self) -> Option<i64>

Source

pub fn into_string(self) -> Option<Arc<String>>

Source

pub fn into_c_string(self) -> Option<*mut i8>

Source

pub fn into_kw_c_string(self) -> Option<*mut i8>

Source

pub fn into_uuid_c_string(self) -> Option<*mut i8>

Source

pub fn into_uuid(self) -> Option<Uuid>

Source

pub fn into_uuid_string(self) -> Option<String>

Source

pub fn into_bytes(self) -> Option<Bytes>

Trait Implementations§

Source§

impl Clone for TypedValue

Source§

fn clone(&self) -> TypedValue

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 TypedValue

Source§

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

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

impl<'de> Deserialize<'de> for TypedValue

Source§

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

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

impl Eq for TypedValue

Source§

impl<'a> From<&'a str> for TypedValue

Source§

fn from(value: &'a str) -> TypedValue

Converts to this type from the input type.
Source§

impl From<&[u8]> for TypedValue

Source§

fn from(bslice: &[u8]) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Arc<Keyword>> for TypedValue

Source§

fn from(value: Arc<Keyword>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Arc<String>> for TypedValue

Source§

fn from(value: Arc<String>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Box<String>> for TypedValue

Source§

fn from(value: Box<String>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<DateTime<Utc>> for TypedValue

Truncate the provided DateTime to microsecond precision, and return the corresponding TypedValue::Instant.

Source§

fn from(value: DateTime<Utc>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Keyword> for TypedValue

Source§

fn from(value: Keyword) -> TypedValue

Converts to this type from the input type.
Source§

impl From<KnownEntid> for TypedValue

Source§

fn from(k: KnownEntid) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Rc<Keyword>> for TypedValue

Source§

fn from(value: Rc<Keyword>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Rc<String>> for TypedValue

Source§

fn from(value: Rc<String>) -> TypedValue

Converts to this type from the input type.
Source§

impl From<String> for TypedValue

Source§

fn from(value: String) -> TypedValue

Converts to this type from the input type.
Source§

impl From<Uuid> for TypedValue

Source§

fn from(value: Uuid) -> TypedValue

Converts to this type from the input type.
Source§

impl From<bool> for TypedValue

Source§

fn from(value: bool) -> TypedValue

Converts to this type from the input type.
Source§

impl From<f64> for TypedValue

Source§

fn from(value: f64) -> TypedValue

Converts to this type from the input type.
Source§

impl From<i32> for TypedValue

Source§

fn from(value: i32) -> TypedValue

Converts to this type from the input type.
Source§

impl From<u32> for TypedValue

Source§

fn from(value: u32) -> TypedValue

Converts to this type from the input type.
Source§

impl Hash for TypedValue

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for TypedValue

Source§

fn cmp(&self, other: &TypedValue) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for TypedValue

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialOrd for TypedValue

Source§

fn partial_cmp(&self, other: &TypedValue) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for TypedValue

Source§

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

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

impl StructuralPartialEq for TypedValue

Source§

impl TransactableValue for TypedValue

Source§

fn into_typed_value( self, _schema: &Schema, value_type: ValueType, ) -> Result<TypedValue, DbError>

Coerce this value place into the given type. This is where we perform schema-aware coercion, for example coercing an integral value into a ref where appropriate.
Source§

fn into_entity_place(self) -> Result<EntityPlace<TypedValue>, DbError>

Make an entity place out of this value place. This is where we limit values in nested maps to valid entity places.
Source§

fn as_tempid(&self) -> Option<TempId>

Source§

fn is_nil(&self) -> bool

Whether this value place is the EDN nil value. Used by :db.fn/cas to recognize “expect no current value”.
Source§

impl TransactableValueMarker for TypedValue

TypedValue is the value type for programmatic use in transaction builders.

Source§

impl TypedSQLValue for TypedValue

Source§

fn from_sql_value_pair( value: Value, value_type_tag: i32, ) -> Result<TypedValue, DbError>

Given a SQLite value and a value_type_tag, return the corresponding TypedValue.

Source§

fn from_edn_value(value: &Value) -> Option<TypedValue>

Given an EDN value, return a corresponding Mentat TypedValue.

An EDN Value does not encode a unique Mentat ValueType, so the composition from_edn_value(first(to_edn_value_pair(...))) loses information. Additionally, there are EDN values which are not Mentat typed values.

This function is deterministic.

Source§

fn to_sql_value_pair(&self) -> (ToSqlOutput<'_>, i32)

Return the corresponding SQLite value and value_type_tag pair.

Source§

fn to_edn_value_pair(&self) -> (Value, ValueType)

Return the corresponding EDN value and value_type pair.

Source§

fn from_sql(value: SqlValue, value_type_tag: i32) -> Result<TypedValue, DbError>

Engine-neutral decode: the one (tag, storage class) table both the SQLite and the DuckDB backends use.
Source§

fn to_sql(&self) -> (SqlValue, i32)

Engine-neutral encode, the inverse of from_sql.

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.