Enum sauron::Value

source ·
pub enum Value {
Show 17 variants Bool(bool), Cow(Cow<'static, str>), Vec(Vec<Value>), U8(u8), U16(u16), U32(u32), U64(u64), Usize(usize), U128(u128), I8(i8), I16(i16), I32(i32), I64(i64), I128(i128), Isize(isize), F32(f32), F64(f64),
}
Expand description

Wraps different primitive variants used as values in html This is needed since html attributes can have different value types such as checked(bool), name(String), tab_index(i32) Note: memory size of Value is 32 bytes, in comparison String is 24 bytes

Variants§

§

Bool(bool)

bool value

§

Cow(Cow<'static, str>)

String value and &’static str

§

Vec(Vec<Value>)

a vec of values

§

U8(u8)

u8 value

§

U16(u16)

u16 value

§

U32(u32)

u32 value

§

U64(u64)

u64 value

§

Usize(usize)

usize value

§

U128(u128)

u128 value

§

I8(i8)

i8 value

§

I16(i16)

i16 value

§

I32(i32)

i32 value

§

I64(i64)

i64 value

§

I128(i128)

i128 value

§

Isize(isize)

isize value

§

F32(f32)

f32 value

§

F64(f64)

f64 value

Implementations§

source§

impl Value

source

pub fn as_str(&self) -> Option<&str>

returns an &str reference if this value is Str or String variant Note: This doesn’t convert other variant into str representation Use the to_string() for that.

source

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

returns the bool value if this a Bool variant

source

pub fn as_f32(&self) -> Option<f32>

converts to f32 if the variants are numerical representation

source

pub fn as_f64(&self) -> Option<f64>

converts to f64 if the variants are numerical representation

source

pub fn as_i32(&self) -> Option<i32>

converts to i32 if the variants are numerical representation

source

pub fn as_i64(&self) -> Option<i64>

converts to i64 if the variants are numerical representation

source

pub fn append(&mut self, new_value: Value)

If this is Value::Vec variant, append the new value otherwise, turn this value into Value::Vec(Vec) variant and append the new value.

Trait Implementations§

source§

impl Clone for Value

source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Value

source§

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

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

impl Display for Value

source§

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

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

impl From<&String> for Value

source§

fn from(v: &String) -> Value

Converts to this type from the input type.
source§

impl From<&'static str> for Value

source§

fn from(v: &'static str) -> Value

Converts to this type from the input type.
source§

impl<T, const N: usize> From<[T; N]> for Value
where T: Into<Value> + Clone,

source§

fn from(v: [T; N]) -> Value

Converts to this type from the input type.
source§

impl<V0, V1> From<(V0, V1)> for Value
where V0: Into<Value>, V1: Into<Value>,

source§

fn from(values: (V0, V1)) -> Value

Converts to this type from the input type.
source§

impl<V0, V1, V2> From<(V0, V1, V2)> for Value
where V0: Into<Value>, V1: Into<Value>, V2: Into<Value>,

source§

fn from(values: (V0, V1, V2)) -> Value

Converts to this type from the input type.
source§

impl<V0, V1, V2, V3> From<(V0, V1, V2, V3)> for Value
where V0: Into<Value>, V1: Into<Value>, V2: Into<Value>, V3: Into<Value>,

source§

fn from(values: (V0, V1, V2, V3)) -> Value

Converts to this type from the input type.
source§

impl<V0, V1, V2, V3, V4> From<(V0, V1, V2, V3, V4)> for Value
where V0: Into<Value>, V1: Into<Value>, V2: Into<Value>, V3: Into<Value>, V4: Into<Value>,

source§

fn from(values: (V0, V1, V2, V3, V4)) -> Value

Converts to this type from the input type.
source§

impl From<String> for Value

source§

fn from(v: String) -> Value

Converts to this type from the input type.
source§

impl From<bool> for Value

source§

fn from(f: bool) -> Value

Converts to this type from the input type.
source§

impl From<f32> for Value

source§

fn from(f: f32) -> Value

Converts to this type from the input type.
source§

impl From<f64> for Value

source§

fn from(f: f64) -> Value

Converts to this type from the input type.
source§

impl From<i128> for Value

source§

fn from(f: i128) -> Value

Converts to this type from the input type.
source§

impl From<i16> for Value

source§

fn from(f: i16) -> Value

Converts to this type from the input type.
source§

impl From<i32> for Value

source§

fn from(f: i32) -> Value

Converts to this type from the input type.
source§

impl From<i64> for Value

source§

fn from(f: i64) -> Value

Converts to this type from the input type.
source§

impl From<i8> for Value

source§

fn from(f: i8) -> Value

Converts to this type from the input type.
source§

impl From<isize> for Value

source§

fn from(f: isize) -> Value

Converts to this type from the input type.
source§

impl From<u128> for Value

source§

fn from(f: u128) -> Value

Converts to this type from the input type.
source§

impl From<u16> for Value

source§

fn from(f: u16) -> Value

Converts to this type from the input type.
source§

impl From<u32> for Value

source§

fn from(f: u32) -> Value

Converts to this type from the input type.
source§

impl From<u64> for Value

source§

fn from(f: u64) -> Value

Converts to this type from the input type.
source§

impl From<u8> for Value

source§

fn from(f: u8) -> Value

Converts to this type from the input type.
source§

impl From<usize> for Value

source§

fn from(f: usize) -> Value

Converts to this type from the input type.
source§

impl PartialEq for Value

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

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<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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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.