pub enum Value {
String(String),
Number(f64),
Path(PathBuf),
Bool(bool),
List(Vec<Value>),
}Expand description
Container for a Value of a specific type
Uses for represent of subjects and properties in Commands( E.g. VerifiedCommand, ExecutableCommand_ )
With wca::Type enum and TryCast you can cast raw string into specific Type.
You can also convert to a type that can be converted from the internal Value type.
§Example:
let command = VerifiedCommand
{
phrase : "command".to_string(),
// Here is numeric value used
subjects : vec![ Value::Number( 3.14 ) ],
properties : HashMap::from_iter(
[
// Here is string value used
( "string_prop".to_string(), Value::String( "value".to_string() ) ),
])
};
let number : f32 = command.subjects[ 0 ].clone().into();
assert_eq!( 3.14, number );
let number : i32 = command.subjects[ 0 ].clone().into();
assert_eq!( 3, number );Variants§
String(String)
String value
Number(f64)
Number value(float number but can be casted to another types)
Path(PathBuf)
Path
Bool(bool)
Bool
List(Vec<Value>)
List
Trait Implementations§
source§impl PartialEq for Value
impl PartialEq for Value
impl StructuralPartialEq 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<S> SetWithType for S
impl<S> SetWithType for S
source§fn set_with_type<T, IntoT>(&mut self, component: IntoT)where
IntoT: Into<T>,
S: SetComponent<T, IntoT>,
fn set_with_type<T, IntoT>(&mut self, component: IntoT)where
IntoT: Into<T>,
S: SetComponent<T, IntoT>,
Function to set value of a component by its type.