pub enum AttributeValue {
String(String),
Integer(i64),
Float(f64),
Boolean(bool),
Json(Value),
}
Expand description
A type-erased attribute value that can store any serializable data
Variants§
String(String)
String attribute
Integer(i64)
Integer attribute
Float(f64)
Float attribute
Boolean(bool)
Boolean attribute
Json(Value)
JSON-serialized arbitrary data
Implementations§
Source§impl AttributeValue
impl AttributeValue
Sourcepub fn json<T: Serialize>(value: &T) -> Result<Self>
pub fn json<T: Serialize>(value: &T) -> Result<Self>
Create a JSON attribute from any serializable type
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Get the attribute as an integer
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Get the attribute as a boolean
Sourcepub fn as_json<T: DeserializeOwned>(&self) -> Result<T>
pub fn as_json<T: DeserializeOwned>(&self) -> Result<T>
Get the attribute as a typed value from JSON
Sourcepub fn to_string_repr(&self) -> String
pub fn to_string_repr(&self) -> String
Convert any attribute value to a string representation
Trait Implementations§
Source§impl Clone for AttributeValue
impl Clone for AttributeValue
Source§fn clone(&self) -> AttributeValue
fn clone(&self) -> AttributeValue
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for AttributeValue
impl Debug for AttributeValue
Source§impl Hash for AttributeValue
impl Hash for AttributeValue
Source§impl PartialEq for AttributeValue
impl PartialEq for AttributeValue
impl Eq for AttributeValue
impl StructuralPartialEq for AttributeValue
Auto Trait Implementations§
impl Freeze for AttributeValue
impl RefUnwindSafe for AttributeValue
impl Send for AttributeValue
impl Sync for AttributeValue
impl Unpin for AttributeValue
impl UnwindSafe for AttributeValue
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.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>
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 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>
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