pub enum AttributeValue {
String(String),
Array(Vec<AttributeValue, Global>),
Number(f64),
Bool(bool),
Object(HashMap<String, AttributeValue, RandomState>),
Null,
}
Expand description
AttributeValue is an enum representing possible values that can be stored in a user attribute.
Variants
String(String)
Used when storing a string value.
Array(Vec<AttributeValue, Global>)
Used when storing an array of AttributeValues.
Number(f64)
Used when storing a number.
Bool(bool)
Used when storing a boolean.
Object(HashMap<String, AttributeValue, RandomState>)
Used when storing a complex map of values.
Null
Used to represent a null value.
Implementations
sourceimpl AttributeValue
impl AttributeValue
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns None unless self is a String. It will not convert.
sourcepub fn to_f64(&self) -> Option<f64>
pub fn to_f64(&self) -> Option<f64>
Returns the wrapped value as a float for numeric types, and None otherwise.
sourcepub fn to_datetime(&self) -> Option<DateTime<Utc>>
pub fn to_datetime(&self) -> Option<DateTime<Utc>>
Attempt to convert any of the following into a chrono::DateTime in UTC:
- RFC3339/ISO8601 timestamp (example: “2016-04-16T17:09:12.759-07:00”)
- Unix epoch milliseconds as number It will return None if the conversion fails or if no conversion is possible.
sourcepub fn as_semver(&self) -> Option<Version>
pub fn as_semver(&self) -> Option<Version>
Attempt to parse a string attribute into a semver version.
It will return None if it cannot parse it, or for non-string attributes.
sourcepub fn find<P>(&self, p: P) -> Option<&AttributeValue> where
P: Fn(&AttributeValue) -> bool,
pub fn find<P>(&self, p: P) -> Option<&AttributeValue> where
P: Fn(&AttributeValue) -> bool,
Find the AttributeValue based off the provided predicate p
.
Trait Implementations
sourceimpl Clone for AttributeValue
impl Clone for AttributeValue
sourcefn clone(&self) -> AttributeValue
fn clone(&self) -> AttributeValue
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for AttributeValue
impl Debug for AttributeValue
sourceimpl<'de> Deserialize<'de> for AttributeValue
impl<'de> Deserialize<'de> for AttributeValue
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<AttributeValue, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<AttributeValue, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'_> From<&'_ str> for AttributeValue
impl<'_> From<&'_ str> for AttributeValue
sourcefn from(s: &str) -> AttributeValue
fn from(s: &str) -> AttributeValue
Converts to this type from the input type.
sourceimpl<S, T> From<HashMap<S, T, RandomState>> for AttributeValue where
String: From<S>,
AttributeValue: From<T>,
impl<S, T> From<HashMap<S, T, RandomState>> for AttributeValue where
String: From<S>,
AttributeValue: From<T>,
sourcefn from(hashmap: HashMap<S, T, RandomState>) -> AttributeValue
fn from(hashmap: HashMap<S, T, RandomState>) -> AttributeValue
Converts to this type from the input type.
sourceimpl From<String> for AttributeValue
impl From<String> for AttributeValue
sourcefn from(s: String) -> AttributeValue
fn from(s: String) -> AttributeValue
Converts to this type from the input type.
sourceimpl<T> From<Vec<T, Global>> for AttributeValue where
AttributeValue: From<T>,
impl<T> From<Vec<T, Global>> for AttributeValue where
AttributeValue: From<T>,
sourcefn from(v: Vec<T, Global>) -> AttributeValue
fn from(v: Vec<T, Global>) -> AttributeValue
Converts to this type from the input type.
sourceimpl From<bool> for AttributeValue
impl From<bool> for AttributeValue
sourcefn from(b: bool) -> AttributeValue
fn from(b: bool) -> AttributeValue
Converts to this type from the input type.
sourceimpl From<f64> for AttributeValue
impl From<f64> for AttributeValue
sourcefn from(f: f64) -> AttributeValue
fn from(f: f64) -> AttributeValue
Converts to this type from the input type.
sourceimpl From<i64> for AttributeValue
impl From<i64> for AttributeValue
sourcefn from(i: i64) -> AttributeValue
fn from(i: i64) -> AttributeValue
Converts to this type from the input type.
sourceimpl<S, T> FromIterator<(S, T)> for AttributeValue where
String: From<S>,
AttributeValue: From<T>,
impl<S, T> FromIterator<(S, T)> for AttributeValue where
String: From<S>,
AttributeValue: From<T>,
sourcefn from_iter<I>(iter: I) -> AttributeValue where
I: IntoIterator<Item = (S, T)>,
fn from_iter<I>(iter: I) -> AttributeValue where
I: IntoIterator<Item = (S, T)>,
Creates a value from an iterator. Read more
sourceimpl<T> FromIterator<T> for AttributeValue where
AttributeValue: From<T>,
impl<T> FromIterator<T> for AttributeValue where
AttributeValue: From<T>,
sourcefn from_iter<I>(iter: I) -> AttributeValue where
I: IntoIterator<Item = T>,
fn from_iter<I>(iter: I) -> AttributeValue where
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
sourceimpl PartialEq<AttributeValue> for AttributeValue
impl PartialEq<AttributeValue> for AttributeValue
sourcefn eq(&self, other: &AttributeValue) -> bool
fn eq(&self, other: &AttributeValue) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &AttributeValue) -> bool
fn ne(&self, other: &AttributeValue) -> bool
This method tests for !=
.
sourceimpl Serialize for AttributeValue
impl Serialize for AttributeValue
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
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
impl StructuralPartialEq for AttributeValue
Auto Trait Implementations
impl RefUnwindSafe for AttributeValue
impl Send for AttributeValue
impl Sync for AttributeValue
impl Unpin for AttributeValue
impl UnwindSafe for AttributeValue
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more