Skip to main content

Value

Struct Value 

Source
pub struct Value { /* private fields */ }

Implementations§

Source§

impl Value

Source

pub fn null() -> Self

Creates a new Value with type Null

Source

pub fn value_type(&self) -> ValueType

Returns the value type of the Value

Source

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

Returns the float value or casts the relevant value to a float

Source

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

Returns the text value if the Value is the proper type

Source

pub fn is_json(&self) -> bool

Source

pub fn to_blob(&self) -> Option<Vec<u8>>

Returns the blob value if the ValueType is Blob

Source

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

Returns the value as an integer (casts or converts if possible)

Source

pub fn to_error(&self) -> Option<ResultCode>

Returns the error code if the value is an error

Source

pub fn to_error_details(&self) -> Option<(ResultCode, Option<String>)>

Returns the error code and optional message if the value is an error

Source

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

Source

pub fn from_integer(i: i64) -> Self

Creates a new integer Value from an i64

Source

pub fn from_float(value: f64) -> Self

Creates a new float Value from a f64

Source

pub fn from_text(s: String) -> Self

Creates a new text Value from a String

Source

pub fn from_json(s: String) -> Self

Source

pub fn error(code: ResultCode) -> Self

Creates a new error Value from a ResultCode

Source

pub fn error_with_message(message: String) -> Self

Creates a new error Value from a ResultCode and a message

Source

pub fn from_blob(value: Vec<u8>) -> Self

Creates a new blob Value from a Vec<u8>

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 Default for Value

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Send for Value

§

impl !Sync for Value

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Unpin for Value

§

impl UnsafeUnpin 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.