Skip to main content

PropertyValue

Enum PropertyValue 

Source
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

Source

pub fn is_auto(&self) -> bool

Check if this is an auto value

Source

pub fn is_none(&self) -> bool

Check if this is a none value

Source

pub fn is_inherit(&self) -> bool

Check if this is an inherit value

Source

pub fn as_length(&self) -> Option<Length>

Try to get a length value

Source

pub fn as_relative_font_size(&self) -> Option<RelativeFontSize>

Try to get a relative font size value

Source

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.

Source

pub fn as_color(&self) -> Option<Color>

Try to get a color value

Source

pub fn as_gradient(&self) -> Option<&Gradient>

Try to get a gradient value

Source

pub fn as_enum(&self) -> Option<u16>

Try to get an enum value

Source

pub fn as_string(&self) -> Option<&str>

Try to get a string value

Source

pub fn as_integer(&self) -> Option<i32>

Try to get an integer value

Source

pub fn as_number(&self) -> Option<f64>

Try to get a number value

Source

pub fn as_boolean(&self) -> Option<bool>

Try to get a boolean value

Source

pub fn as_percentage(&self) -> Option<Percentage>

Try to get a percentage value

Source

pub fn resolve_length(&self, base: Length) -> Option<Length>

Resolve a value to a length, applying percentage if needed

Source

pub fn as_expression(&self) -> Option<&Expression>

Try to get an expression value

Source

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

Source§

fn clone(&self) -> PropertyValue

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PropertyValue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PropertyValue

Source§

fn eq(&self, other: &PropertyValue) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PropertyValue

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.