pub struct Value { /* private fields */ }
Expand description
A generic value capable of carrying various types.
Once created the type of the value can’t be changed.
Some types (e.g. String
and objects) support None
values while others
(e.g. numeric types) don’t.
Value
does not implement the Send
trait, but SendValue
can be
used instead.
See the module documentation for more details.
Implementations§
§impl Value
impl Value
pub fn for_value_type<T>() -> Valuewhere
T: ValueType,
pub fn for_value_type<T>() -> Valuewhere T: ValueType,
Creates a new Value
that is initialized for a given ValueType
.
pub fn get<'a, T>(
&'a self
) -> Result<T, <<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>where
T: FromValue<'a>,
pub fn get<'a, T>( &'a self ) -> Result<T, <<T as FromValue<'a>>::Checker as ValueTypeChecker>::Error>where T: FromValue<'a>,
Tries to get a value of type T
.
Returns Ok
if the type is correct.
pub fn get_owned<T>(
&self
) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where
T: for<'b> FromValue<'b> + 'static,
pub fn get_owned<T>( &self ) -> Result<T, <<T as FromValue<'_>>::Checker as ValueTypeChecker>::Error>where T: for<'b> FromValue<'b> + 'static,
Tries to get a value of an owned type T
.
pub fn is<T>(&self) -> boolwhere
T: StaticType,
pub fn is<T>(&self) -> boolwhere T: StaticType,
Returns true
if the type of the value corresponds to T
or is a sub-type of T
.
pub fn is_type(&self, type_: Type) -> bool
pub fn is_type(&self, type_: Type) -> bool
Returns true
if the type of the value corresponds to type_
or is a sub-type of type_
.
pub fn type_transformable(src: Type, dst: Type) -> bool
pub fn type_transformable(src: Type, dst: Type) -> bool
Returns whether Value
s of type src
can be transformed to type dst
.
pub fn transform<T>(&self) -> Result<Value, BoolError>where
T: ValueType,
pub fn transform<T>(&self) -> Result<Value, BoolError>where T: ValueType,
Tries to transform the value into a value of the target type
pub fn transform_with_type(&self, type_: Type) -> Result<Value, BoolError>
pub fn transform_with_type(&self, type_: Type) -> Result<Value, BoolError>
Tries to transform the value into a value of the target type
pub fn try_into_send_value<T>(self) -> Result<SendValue, Value>where T: Send + StaticType,
Trait Implementations§
§impl<'a> FromValue<'a> for &'a Value
impl<'a> FromValue<'a> for &'a Value
§type Checker = NopChecker
type Checker = NopChecker
§unsafe fn from_value(value: &'a Value) -> &'a Value
unsafe fn from_value(value: &'a Value) -> &'a Value
Value
. Read more§impl<'a> FromValue<'a> for Value
impl<'a> FromValue<'a> for Value
§type Checker = NopChecker
type Checker = NopChecker
§unsafe fn from_value(value: &'a Value) -> Value
unsafe fn from_value(value: &'a Value) -> Value
Value
. Read more