pub enum PropertyValue {
Show 16 variants
Length(Length),
Color(Color),
Gradient(Gradient),
Enum(u16),
String(Cow<'static, str>),
Percentage(Percentage),
Integer(i32),
Number(f64),
Boolean(bool),
List(Vec<PropertyValue>),
Pair(Box<PropertyValue>, Box<PropertyValue>),
RelativeFontSize(RelativeFontSize),
Expression(Expression),
Auto,
None,
Inherit,
}Expand description
A property value that can be stored in a PropertyList
Variants§
Length(Length)
A length value (e.g., “10pt”, “2cm”)
Color(Color)
A color value (e.g., “#FF0000”, “red”)
Gradient(Gradient)
A gradient value (e.g., “linear-gradient(red, blue)”)
Enum(u16)
An enumerated value (stored as u16 for compactness)
String(Cow<'static, str>)
A string value (borrowed or owned)
Percentage(Percentage)
A percentage value (e.g., 50%, 100%)
Integer(i32)
An integer value
Number(f64)
A floating-point value
Boolean(bool)
A boolean value
List(Vec<PropertyValue>)
A list of values
Pair(Box<PropertyValue>, Box<PropertyValue>)
A space-separated pair of values
RelativeFontSize(RelativeFontSize)
A relative font-size value (larger, smaller, or size keywords)
Expression(Expression)
A CSS calc() expression
Auto
The special value “auto”
None
The special value “none”
Inherit
The special value “inherit”
Implementations§
Source§impl PropertyValue
impl PropertyValue
Sourcepub fn is_inherit(&self) -> bool
pub fn is_inherit(&self) -> bool
Check if this is an inherit value
Sourcepub fn as_relative_font_size(&self) -> Option<RelativeFontSize>
pub fn as_relative_font_size(&self) -> Option<RelativeFontSize>
Try to get a relative font size value
Sourcepub fn resolve_font_size(&self, parent_size: Length) -> Option<Length>
pub fn resolve_font_size(&self, parent_size: Length) -> Option<Length>
Resolve a font size value to an absolute length
If the value is a relative font size (larger/smaller/keywords), it will be resolved using the parent font size.
Sourcepub fn as_gradient(&self) -> Option<&Gradient>
pub fn as_gradient(&self) -> Option<&Gradient>
Try to get a gradient value
Sourcepub fn as_integer(&self) -> Option<i32>
pub fn as_integer(&self) -> Option<i32>
Try to get an integer value
Sourcepub fn as_boolean(&self) -> Option<bool>
pub fn as_boolean(&self) -> Option<bool>
Try to get a boolean value
Sourcepub fn as_percentage(&self) -> Option<Percentage>
pub fn as_percentage(&self) -> Option<Percentage>
Try to get a percentage value
Sourcepub fn resolve_length(&self, base: Length) -> Option<Length>
pub fn resolve_length(&self, base: Length) -> Option<Length>
Resolve a value to a length, applying percentage if needed
Sourcepub fn as_expression(&self) -> Option<&Expression>
pub fn as_expression(&self) -> Option<&Expression>
Try to get an expression value
Sourcepub fn resolve_with_context(&self, context: &EvalContext) -> Option<Length>
pub fn resolve_with_context(&self, context: &EvalContext) -> Option<Length>
Resolve a value to a length, evaluating expressions if needed
Trait Implementations§
Source§impl Clone for PropertyValue
impl Clone for PropertyValue
Source§fn clone(&self) -> PropertyValue
fn clone(&self) -> PropertyValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more