#[non_exhaustive]pub enum AttrValue {
Null,
Text(String),
Int(i64),
Float(f64),
Bool(bool),
DateTime(DateTime<Utc>),
Json(Value),
}Expand description
One attribute’s value.
Non-exhaustive: variants are added as the storage layer learns to bind them,
so match with a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Null
No value. Stored as SQL NULL, distinct from an empty string.
Text(String)
Int(i64)
Float(f64)
Bool(bool)
DateTime(DateTime<Utc>)
An instant, always UTC. Rendered as RFC 3339 with microsecond precision, the one timestamp format the framework stores.
Json(Value)
Implementations§
Source§impl AttrValue
impl AttrValue
Sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Whether this is AttrValue::Null.
Sourcepub fn to_text(&self) -> Option<String>
pub fn to_text(&self) -> Option<String>
The storage text for this value, or None for AttrValue::Null.
This is the lossy bridge to the all-text write path; typed binding replaces it where the storage layer can bind a value natively.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
The text, when this is AttrValue::Text.
Sourcepub fn as_int(&self) -> Option<i64>
pub fn as_int(&self) -> Option<i64>
The integer, when this is AttrValue::Int.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
The float, when this is AttrValue::Float (or an AttrValue::Int,
widened).
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
The boolean, when this is AttrValue::Bool.
Sourcepub fn as_datetime(&self) -> Option<DateTime<Utc>>
pub fn as_datetime(&self) -> Option<DateTime<Utc>>
The instant, when this is AttrValue::DateTime.
Sourcepub fn as_json(&self) -> Option<&Value>
pub fn as_json(&self) -> Option<&Value>
The JSON, when this is AttrValue::Json.
Trait Implementations§
Source§impl<T: Into<AttrValue>> From<Option<T>> for AttrValue
None becomes AttrValue::Null, so an optional column reads naturally.
impl<T: Into<AttrValue>> From<Option<T>> for AttrValue
None becomes AttrValue::Null, so an optional column reads naturally.
impl StructuralPartialEq for AttrValue
Auto Trait Implementations§
impl Freeze for AttrValue
impl RefUnwindSafe for AttrValue
impl Send for AttrValue
impl Sync for AttrValue
impl Unpin for AttrValue
impl UnsafeUnpin for AttrValue
impl UnwindSafe for AttrValue
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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