Value

Enum Value 

Source
pub enum Value {
    String(String),
    Bool(bool),
    Bytes(Vec<u8>),
    Char(char),
    Option(Option<Box<Value>>),
    UInt(u128),
    Int(i128),
    Float(f64),
}
Expand description

The value used for templating.

§Automatic convertation into string

  • string -> string
  • char -> string
  • uint -> string using decimal base.
  • int -> string using decimal base with sign.
  • bytes -> utf-8 encoded string or error
  • bool -> error. For convertation boolean type use bool:to_string
  • option -> error. For convertation option use string:unwrap_or, uint:unwrap_or or others.
  • float -> error. For convertation option use float:to_string.

Variants§

§

String(String)

Value that contains string type.

§

Bool(bool)

Value that contains boolean type.

§

Bytes(Vec<u8>)

Value that contains array of bytes.

§

Char(char)

Value that contains char.

§

Option(Option<Box<Value>>)

Value that may contain other value.

§

UInt(u128)

Value that contains unsigned 128-bit integer.

§

Int(i128)

Value that contains signed 128-bit integer.

§

Float(f64)

Value that contains float value.

Implementations§

Source§

impl Value

Source

pub fn as_string(&self) -> Result<&String, FunctionError>

Trying to cast value as string.

Source

pub fn as_mut_string(&mut self) -> Result<&mut String, FunctionError>

Trying to cast value as mutable string.

Source

pub fn into_string(self) -> Result<String, FunctionError>

Trying to cast value as string.

Source

pub fn as_bool(&self) -> Result<&bool, FunctionError>

Trying to cast value as bool.

Source

pub fn as_mut_bool(&mut self) -> Result<&mut bool, FunctionError>

Trying to cast value as mutable bool.

Source

pub fn into_bool(self) -> Result<bool, FunctionError>

Trying to cast value as bool.

Source

pub fn as_bytes(&self) -> Result<&Vec<u8>, FunctionError>

Trying to cast value as bytes.

Source

pub fn as_mut_bytes(&mut self) -> Result<&mut Vec<u8>, FunctionError>

Trying to cast value as mutable bytes.

Source

pub fn into_bytes(self) -> Result<Vec<u8>, FunctionError>

Trying to cast value as bytes.

Source

pub fn as_char(&self) -> Result<&char, FunctionError>

Trying to cast value as char.

Source

pub fn as_mut_char(&mut self) -> Result<&mut char, FunctionError>

Trying to cast value as mutable char.

Source

pub fn as_option(&self) -> Result<Option<&Value>, FunctionError>

Trying to cast value as option.

Source

pub fn as_mut_option(&mut self) -> Result<Option<&mut Value>, FunctionError>

Trying to cast value as mutable option.

Source

pub fn into_option(self) -> Result<Option<Value>, FunctionError>

Trying to cast value as option.

Source

pub fn as_uint(&self) -> Result<&u128, FunctionError>

Trying to cast value as uint.

Source

pub fn as_mut_uint(&mut self) -> Result<&mut u128, FunctionError>

Trying to cast value as mutable uint.

Source

pub fn into_uint(self) -> Result<u128, FunctionError>

Trying to cast value as uint.

Source

pub fn as_int(&self) -> Result<&i128, FunctionError>

Trying to cast value as int.

Source

pub fn as_mut_int(&mut self) -> Result<&mut i128, FunctionError>

Trying to cast value as mutable int.

Source

pub fn into_int(self) -> Result<i128, FunctionError>

Trying to cast value as int.

Source

pub fn as_float(&self) -> Result<&f64, FunctionError>

Trying to cast value as float.

Source

pub fn as_mut_float(&mut self) -> Result<&mut f64, FunctionError>

Trying to cast value as mutable float.

Source

pub fn floato_float(self) -> Result<f64, FunctionError>

Trying to cast value as float.

Trait Implementations§

Source§

impl Debug for Value

Source§

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

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

impl Serialize for Value

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.