pub enum BindingValue {
String(String),
Integer(i64),
Float(f64),
Bool(bool),
List(Vec<BindingValue>),
Object(HashMap<String, BindingValue>),
None,
}Expand description
Value returned from a binding evaluation
This enum represents all possible types that can be produced by evaluating a binding expression.
§Variants
String- Text valuesInteger- Whole numbersFloat- Decimal numbersBool- Boolean valuesList- Collections of valuesObject- Key-value mappings (for structs/records)None- Absence of value
Variants§
String(String)
String value
Integer(i64)
Integer value
Float(f64)
Floating-point value
Bool(bool)
Boolean value
List(Vec<BindingValue>)
List of values
Object(HashMap<String, BindingValue>)
Object/record with named fields
None
No value (null/none)
Implementations§
Source§impl BindingValue
impl BindingValue
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Convert to display string for rendering
Used when a binding value needs to be displayed as text.
§Examples
use dampen_core::BindingValue;
let val = BindingValue::Integer(42);
assert_eq!(val.to_display_string(), "42");Sourcepub fn to_bool(&self) -> bool
pub fn to_bool(&self) -> bool
Convert to boolean for conditionals
Used when a binding is used in a boolean context like enabled="{condition}".
§Truthiness Rules
Bool(true)→true- Non-empty strings →
true - Non-zero numbers →
true - Non-empty lists →
true None→false
Sourcepub fn from_value<T: ToBindingValue>(value: &T) -> Self
pub fn from_value<T: ToBindingValue>(value: &T) -> Self
Create BindingValue from a value
Convenience method for converting types that implement ToBindingValue.
Sourcepub fn get_field(&self, field_name: &str) -> Option<BindingValue>
pub fn get_field(&self, field_name: &str) -> Option<BindingValue>
Get a field from an Object binding value
Returns None if this is not an Object or the field doesn’t exist.
Trait Implementations§
Source§impl Clone for BindingValue
impl Clone for BindingValue
Source§fn clone(&self) -> BindingValue
fn clone(&self) -> BindingValue
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BindingValue
impl Debug for BindingValue
Source§impl<'de> Deserialize<'de> for BindingValue
impl<'de> Deserialize<'de> for BindingValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for BindingValue
impl PartialEq for BindingValue
Source§impl Serialize for BindingValue
impl Serialize for BindingValue
impl StructuralPartialEq for BindingValue
Auto Trait Implementations§
impl Freeze for BindingValue
impl RefUnwindSafe for BindingValue
impl Send for BindingValue
impl Sync for BindingValue
impl Unpin for BindingValue
impl UnwindSafe for BindingValue
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