Struct Value

Source
#[repr(C)]
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

§Safety

This function accesses the value_type field of the union. it is safe to call this function as long as the value was properly constructed with one of the provided methods

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 to_blob(&self) -> Option<Vec<u8>>

Returns the blob value if the Value is the proper type

Source

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

Returns the integer value if the Value is the proper type

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 This function allocates/leaks the string and must be free’d manually

Source

pub fn error(code: ResultCode) -> Self

Creates a new error Value from a ResultCode This function allocates/leaks the error and must be free’d manually

Source

pub fn error_with_message(message: String) -> Self

Creates a new error Value from a ResultCode and a message This function allocates/leaks the error, must be free’d manually

Source

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

Creates a new blob Value from a Vec This function allocates/leaks the blob and must be free’d manually

Source

pub unsafe fn free(self)

§Safety

consumes the value while freeing the underlying memory with null check. however this does assume that the type was properly constructed with the appropriate value_type and value.

Trait Implementations§

Source§

impl Debug for Value

Source§

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

Formats the value using the given formatter. 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.