pub enum Number {
}Expand description
Represents a numeric value with optional unit or calculation.
Supports absolute values, percentages, viewport units, and calculated expressions. Can be evaluated to a concrete value given container and viewport dimensions.
Variants§
Real(f32)
Floating-point absolute value.
Integer(i64)
Integer absolute value.
RealPercent(f32)
Floating-point percentage of container.
IntegerPercent(i64)
Integer percentage of container.
RealDvw(f32)
Floating-point dynamic viewport width percentage.
IntegerDvw(i64)
Integer dynamic viewport width percentage.
RealDvh(f32)
Floating-point dynamic viewport height percentage.
IntegerDvh(i64)
Integer dynamic viewport height percentage.
RealVw(f32)
Floating-point viewport width percentage.
IntegerVw(i64)
Integer viewport width percentage.
RealVh(f32)
Floating-point viewport height percentage.
IntegerVh(i64)
Integer viewport height percentage.
Calc(Calculation)
Calculated expression.
Implementations§
Source§impl Number
impl Number
Sourcepub fn calc(&self, container: f32, view_width: f32, view_height: f32) -> f32
pub fn calc(&self, container: f32, view_width: f32, view_height: f32) -> f32
Evaluates this number to a concrete pixel value.
Percentages are calculated relative to container, viewport units relative to
view_width and view_height.
Sourcepub fn as_dynamic(&self) -> Option<&Self>
pub fn as_dynamic(&self) -> Option<&Self>
Returns a reference to this number if it is dynamic.
Dynamic numbers depend on container size (percentages).
Sourcepub fn is_dynamic(&self) -> bool
pub fn is_dynamic(&self) -> bool
Checks if this number is dynamic.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Number
impl<'de> Deserialize<'de> for Number
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>,
Source§impl From<HeaderSize> for Number
impl From<HeaderSize> for Number
Source§fn from(value: HeaderSize) -> Self
fn from(value: HeaderSize) -> Self
Source§impl From<IfExpression<f32, Responsive>> for Number
Available on crate feature logic only.
impl From<IfExpression<f32, Responsive>> for Number
logic only.Source§fn from(if_expr: IfExpression<f32, Responsive>) -> Self
fn from(if_expr: IfExpression<f32, Responsive>) -> Self
Source§impl From<IfExpression<i32, Responsive>> for Number
Available on crate feature logic only.
impl From<IfExpression<i32, Responsive>> for Number
logic only.Source§fn from(if_expr: IfExpression<i32, Responsive>) -> Self
fn from(if_expr: IfExpression<i32, Responsive>) -> Self
Source§impl From<IfExpression<i64, Responsive>> for Number
Available on crate feature logic only.
impl From<IfExpression<i64, Responsive>> for Number
logic only.