pub enum Value {
Show 16 variants
Bang(String),
Call(String, CallArgs),
Function(String, Option<Function>),
Literal(CssString),
List(Vec<Value>, Option<ListSeparator>, bool),
Numeric(Numeric, bool),
Color(Color, Option<String>),
Null,
True,
False,
BinOp(Box<BinOp>),
UnaryOp(Operator, Box<Value>),
Map(ValueMap),
UnicodeRange(String),
Paren(Box<Value>),
ArgList(CallArgs),
}
Expand description
A css value.
Variants§
Bang(String)
A special kind of escape. Only really used for !important.
Call(String, CallArgs)
An function call that was not evaluated.
Function(String, Option<Function>)
A (callable?) function.
Literal(CssString)
A string literal.
List(Vec<Value>, Option<ListSeparator>, bool)
A comma- or space separated list of values, with or without brackets.
Numeric(Numeric, bool)
A Numeric value is a rational value with a Unit (which may be Unit::None) and flags.
The boolean flag is true for calculated values and false for literal values.
Color(Color, Option<String>)
A color value (and optionally, its source string).
Null
The null value.
True
The true boolean value.
False
The false boolean value.
BinOp(Box<BinOp>)
A binary operation, two operands and an operator. The booleans represents possible whitespace.
UnaryOp(Operator, Box<Value>)
A unary operator and its operand.
Map(ValueMap)
A map of values.
UnicodeRange(String)
A unicode range for font selections. U+NN, U+N?, U+NN-MM. The string is the entire value, including the “U+” tag.
Paren(Box<Value>)
A value in parenthesis.
ArgList(CallArgs)
An argumentt list
Implementations§
source§impl Value
impl Value
sourcepub fn valid_css(self) -> Result<Self, InvalidCss>
pub fn valid_css(self) -> Result<Self, InvalidCss>
Check that the value is valid in css.
sourcepub fn is_calculation(&self) -> bool
pub fn is_calculation(&self) -> bool
Returns true if this is a css calc(...)
function.
sourcepub fn is_calculated(&self) -> bool
pub fn is_calculated(&self) -> bool
Return true if this is a calculated value.
The return of functions or operators are calculated, verbatim values are not.
sourcepub fn into_calculated(self) -> Self
pub fn into_calculated(self) -> Self
Get this value, but marked as calculated.
Make sure arithmetic operators are evaluated.
sourcepub fn is_null(&self) -> bool
pub fn is_null(&self) -> bool
Return true if this value is null.
Note that an empty unquoted string and a list containing no non-null values is also considered null.
sourcepub fn numeric_value(self) -> Result<Numeric, Self>
pub fn numeric_value(self) -> Result<Numeric, Self>
Check if this value is numeric.
If it is, get the number and unit, otherwise, get the value itself as error.
sourcepub fn unquote(self) -> Value
pub fn unquote(self) -> Value
Unquote this value.
If the value is a quoted string, the content is unquoted.
sourcepub fn iter_items(self) -> Vec<Value>
pub fn iter_items(self) -> Vec<Value>
Get this value as iterable items.
Lists and maps have iterable items, which are returned as a vector of values. Other values are returned as a vec containing the value as a single item.
sourcepub fn format(&self, format: Format) -> Formatted<'_, Value>
pub fn format(&self, format: Format) -> Formatted<'_, Value>
Get a reference to this Value
bound to an output format.
The bound reference implements Display
, so it can be written
with the rust format!(...)
macros or coverted with the
to_string()
method.
Example
assert_eq!(
Value::scalar(42).format(Default::default()).to_string(),
"42",
);
sourcepub fn introspect(&self) -> String
pub fn introspect(&self) -> String
Format this value for error messages.
Trait Implementations§
source§impl PartialEq for Value
impl PartialEq for Value
Some Values are equal according to spec even with some implementation differences.
source§impl PartialOrd for Value
impl PartialOrd for Value
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more