Skip to main content

AttributeValueExt

Trait AttributeValueExt 

Source
pub trait AttributeValueExt {
    // Required methods
    fn as_string(&self) -> Option<&MetaString>;
    fn as_float(&self) -> Option<f64>;
    fn as_bool(&self) -> Option<bool>;
    fn as_int(&self) -> Option<i64>;
    fn as_num(&self) -> Option<f64>;
    fn as_bytes(&self) -> Option<&[u8]>;
}
Expand description

Saluki’s accessors for AttributeValue.

AttributeValue is a type alias for a generic type from another crate, so these accessors are on a trait. Import the trait to call them.

Required Methods§

Source

fn as_string(&self) -> Option<&MetaString>

Returns the inner string if this is a String variant.

Source

fn as_float(&self) -> Option<f64>

Returns the inner float if this is a Float variant.

Returns Some only when the stored variant is Float. For numeric semantic tags where the source may store an integer (for example, sampling priority, _sample_rate, _top_level), use as_num instead.

Source

fn as_bool(&self) -> Option<bool>

Returns the inner bool if this is a Bool variant.

Source

fn as_int(&self) -> Option<i64>

Returns the inner integer if this is an Int variant.

Source

fn as_num(&self) -> Option<f64>

Returns a numeric value as f64 for either Float or Int variants.

Use this when the caller only needs a number and doesn’t care whether the stored type is integral or floating-point (for example, sampling priority).

Source

fn as_bytes(&self) -> Option<&[u8]>

Returns the inner bytes if this is a Bytes variant.

Implementors§