Enum LengthValue

Source
pub enum LengthValue {
Show 49 variants Px(CSSNumber), In(CSSNumber), Cm(CSSNumber), Mm(CSSNumber), Q(CSSNumber), Pt(CSSNumber), Pc(CSSNumber), Em(CSSNumber), Rem(CSSNumber), Ex(CSSNumber), Rex(CSSNumber), Ch(CSSNumber), Rch(CSSNumber), Cap(CSSNumber), Rcap(CSSNumber), Ic(CSSNumber), Ric(CSSNumber), Lh(CSSNumber), Rlh(CSSNumber), Vw(CSSNumber), Lvw(CSSNumber), Svw(CSSNumber), Dvw(CSSNumber), Cqw(CSSNumber), Vh(CSSNumber), Lvh(CSSNumber), Svh(CSSNumber), Dvh(CSSNumber), Cqh(CSSNumber), Vi(CSSNumber), Svi(CSSNumber), Lvi(CSSNumber), Dvi(CSSNumber), Cqi(CSSNumber), Vb(CSSNumber), Svb(CSSNumber), Lvb(CSSNumber), Dvb(CSSNumber), Cqb(CSSNumber), Vmin(CSSNumber), Svmin(CSSNumber), Lvmin(CSSNumber), Dvmin(CSSNumber), Cqmin(CSSNumber), Vmax(CSSNumber), Svmax(CSSNumber), Lvmax(CSSNumber), Dvmax(CSSNumber), Cqmax(CSSNumber),
}
Expand description

A CSS <length> value, without support for calc(). See also: Length.

Variants§

§

Px(CSSNumber)

A length in pixels.

§

In(CSSNumber)

A length in inches. 1in = 96px.

§

Cm(CSSNumber)

A length in centimeters. 1cm = 96px / 2.54.

§

Mm(CSSNumber)

A length in millimeters. 1mm = 1/10th of 1cm.

§

Q(CSSNumber)

A length in quarter-millimeters. 1Q = 1/40th of 1cm.

§

Pt(CSSNumber)

A length in points. 1pt = 1/72nd of 1in.

§

Pc(CSSNumber)

A length in picas. 1pc = 1/6th of 1in.

§

Em(CSSNumber)

A length in the em unit. An em is equal to the computed value of the font-size property of the element on which it is used.

§

Rem(CSSNumber)

A length in the rem unit. A rem is equal to the computed value of the em unit on the root element.

§

Ex(CSSNumber)

A length in ex unit. An ex is equal to the x-height of the font.

§

Rex(CSSNumber)

A length in the rex unit. A rex is equal to the value of the ex unit on the root element.

§

Ch(CSSNumber)

A length in the ch unit. A ch is equal to the width of the zero (“0”) character in the current font.

§

Rch(CSSNumber)

A length in the rch unit. An rch is equal to the value of the ch unit on the root element.

§

Cap(CSSNumber)

A length in the cap unit. A cap is equal to the cap-height of the font.

§

Rcap(CSSNumber)

A length in the rcap unit. An rcap is equal to the value of the cap unit on the root element.

§

Ic(CSSNumber)

A length in the ic unit. An ic is equal to the width of the “水” (CJK water ideograph) character in the current font.

§

Ric(CSSNumber)

A length in the ric unit. An ric is equal to the value of the ic unit on the root element.

§

Lh(CSSNumber)

A length in the lh unit. An lh is equal to the computed value of the line-height property.

§

Rlh(CSSNumber)

A length in the rlh unit. An rlh is equal to the value of the lh unit on the root element.

§

Vw(CSSNumber)

A length in the vw unit. A vw is equal to 1% of the viewport width.

§

Lvw(CSSNumber)

A length in the lvw unit. An lvw is equal to 1% of the large viewport width.

§

Svw(CSSNumber)

A length in the svw unit. An svw is equal to 1% of the small viewport width.

§

Dvw(CSSNumber)

A length in the dvw unit. An dvw is equal to 1% of the dynamic viewport width.

§

Cqw(CSSNumber)

A length in the cqw unit. An cqw is equal to 1% of the query container width.

§

Vh(CSSNumber)

A length in the vh unit. A vh is equal to 1% of the viewport height.

§

Lvh(CSSNumber)

A length in the lvh unit. An lvh is equal to 1% of the large viewport height.

§

Svh(CSSNumber)

A length in the svh unit. An svh is equal to 1% of the small viewport height.

§

Dvh(CSSNumber)

A length in the dvh unit. An dvh is equal to 1% of the dynamic viewport height.

§

Cqh(CSSNumber)

A length in the cqh unit. An cqh is equal to 1% of the query container height.

§

Vi(CSSNumber)

A length in the vi unit. A vi is equal to 1% of the viewport size in the box’s inline axis.

§

Svi(CSSNumber)

A length in the svi unit. A svi is equal to 1% of the small viewport size in the box’s inline axis.

§

Lvi(CSSNumber)

A length in the lvi unit. A lvi is equal to 1% of the large viewport size in the box’s inline axis.

§

Dvi(CSSNumber)

A length in the dvi unit. A dvi is equal to 1% of the dynamic viewport size in the box’s inline axis.

§

Cqi(CSSNumber)

A length in the cqi unit. An cqi is equal to 1% of the query container inline size.

§

Vb(CSSNumber)

A length in the vb unit. A vb is equal to 1% of the viewport size in the box’s block axis.

§

Svb(CSSNumber)

A length in the svb unit. A svb is equal to 1% of the small viewport size in the box’s block axis.

§

Lvb(CSSNumber)

A length in the lvb unit. A lvb is equal to 1% of the large viewport size in the box’s block axis.

§

Dvb(CSSNumber)

A length in the dvb unit. A dvb is equal to 1% of the dynamic viewport size in the box’s block axis.

§

Cqb(CSSNumber)

A length in the cqb unit. An cqb is equal to 1% of the query container block size.

§

Vmin(CSSNumber)

A length in the vmin unit. A vmin is equal to the smaller of vw and vh.

§

Svmin(CSSNumber)

A length in the svmin unit. An svmin is equal to the smaller of svw and svh.

§

Lvmin(CSSNumber)

A length in the lvmin unit. An lvmin is equal to the smaller of lvw and lvh.

§

Dvmin(CSSNumber)

A length in the dvmin unit. A dvmin is equal to the smaller of dvw and dvh.

§

Cqmin(CSSNumber)

A length in the cqmin unit. An cqmin is equal to the smaller of cqi and cqb.

§

Vmax(CSSNumber)

A length in the vmax unit. A vmax is equal to the larger of vw and vh.

§

Svmax(CSSNumber)

A length in the svmax unit. An svmax is equal to the larger of svw and svh.

§

Lvmax(CSSNumber)

A length in the lvmax unit. An lvmax is equal to the larger of lvw and lvh.

§

Dvmax(CSSNumber)

A length in the dvmax unit. An dvmax is equal to the larger of dvw and dvh.

§

Cqmax(CSSNumber)

A length in the cqmax unit. An cqmin is equal to the larger of cqi and cqb.

Implementations§

Source§

impl LengthValue

Source

pub fn to_unit_value(&self) -> (CSSNumber, &str)

Returns the numeric value and unit string for the length value.

Source§

impl LengthValue

Source

pub fn to_px(&self) -> Option<CSSNumber>

Attempts to convert the value to pixels. Returns None if the conversion is not possible.

Trait Implementations§

Source§

impl Clone for LengthValue

Source§

fn clone(&self) -> LengthValue

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 LengthValue

Source§

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

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

impl<'de> Deserialize<'de> for LengthValue

Source§

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<'any> IntoOwned<'any> for LengthValue

Source§

type Owned = LengthValue

A variant of Self with a new lifetime.
Source§

fn into_owned(self) -> Self

Make lifetime of self 'static.
Source§

impl IsCompatible for LengthValue

Source§

fn is_compatible(&self, browsers: Browsers) -> bool

Returns whether the value is compatible with all of the given browser targets.
Source§

impl JsonSchema for LengthValue

Available on crate feature jsonschema only.
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl Map for LengthValue

Source§

fn map<F: FnOnce(f32) -> f32>(&self, op: F) -> Self

Returns the result of the operation.
Source§

impl Mul<f32> for LengthValue

Source§

type Output = LengthValue

The resulting type after applying the * operator.
Source§

fn mul(self, other: CSSNumber) -> LengthValue

Performs the * operation. Read more
Source§

impl<'i> Parse<'i> for LengthValue

Source§

fn parse<'t>( input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i, ParserError<'i>>>

Parse a value of this type using an existing parser.
Source§

fn parse_string(input: &'i str) -> Result<Self, ParseError<'i, ParserError<'i>>>

Parse a value from a string. Read more
Source§

impl PartialEq for LengthValue

Source§

fn eq(&self, other: &LengthValue) -> 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 PartialOrd for LengthValue

Source§

fn partial_cmp(&self, other: &LengthValue) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for LengthValue

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Sign for LengthValue

Source§

fn sign(&self) -> f32

Returns the sign of the value.
Source§

fn is_sign_positive(&self) -> bool

Returns whether the value is positive.
Source§

fn is_sign_negative(&self) -> bool

Returns whether the value is negative.
Source§

impl ToCss for LengthValue

Source§

fn to_css<W>( &self, dest: &mut Printer<'_, '_, '_, W>, ) -> Result<(), PrinterError>
where W: Write,

Serialize self in CSS syntax, writing to dest.
Source§

fn to_css_string( &self, options: PrinterOptions<'_>, ) -> Result<String, PrinterError>

Serialize self in CSS syntax and return a string. Read more
Source§

impl<'i> TryFrom<&Token<'i>> for LengthValue

Source§

type Error = ()

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

fn try_from(token: &Token<'_>) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Angle> for LengthValue

Source§

type Error = ()

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

fn try_from(_: Angle) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryOp for LengthValue

Source§

fn try_op<F: FnOnce(f32, f32) -> f32>(&self, rhs: &Self, op: F) -> Option<Self>

Returns the result of the operation in the same type, if possible.
Source§

fn try_op_to<T, F: FnOnce(f32, f32) -> T>(&self, rhs: &Self, op: F) -> Option<T>

Returns the result of the operation in a different type, if possible.
Source§

impl<'i, __T: Visit<'i, __T, __V>, __V: ?Sized + Visitor<'i, __T>> Visit<'i, __T, __V> for LengthValue

Source§

const CHILD_TYPES: VisitTypes

Available on crate feature visitor only.
The types of values contained within this value and its children. This is used to skip branches that don’t have any values requested by the Visitor.
Source§

fn visit(&mut self, visitor: &mut __V) -> Result<(), __V::Error>

Available on crate feature visitor only.
Visits the value by calling an appropriate method on the Visitor. If no corresponding visitor method exists, then the children are visited.
Source§

fn visit_children(&mut self, visitor: &mut __V) -> Result<(), __V::Error>

Available on crate feature visitor only.
Visit the children of this value.
Source§

impl Zero for LengthValue

Source§

fn zero() -> Self

Returns the zero value.
Source§

fn is_zero(&self) -> bool

Returns whether the value is zero.
Source§

impl StructuralPartialEq for LengthValue

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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'i, T> ParseWithOptions<'i> for T
where T: Parse<'i>,

Source§

fn parse_with_options<'t>( input: &mut Parser<'i, 't>, _options: &ParserOptions<'_, '_>, ) -> Result<T, ParseError<'i, ParserError<'i>>>

Parse a value of this type with the given options.
Source§

fn parse_string_with_options( input: &'i str, options: ParserOptions<'_, 'i>, ) -> Result<Self, ParseError<'i, ParserError<'i>>>

Parse a value from a string with the given options.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
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.
Source§

impl<T> TryMap for T
where T: Map,

Source§

fn try_map<F>(&self, op: F) -> Option<T>
where F: FnOnce(f32) -> f32,

Returns the result of the operation, if possible.
Source§

impl<T> TrySign for T
where T: Sign,

Source§

fn try_sign(&self) -> Option<f32>

Returns the sign of the value, if possible.
Source§

fn is_sign_positive(&self) -> bool

Returns whether the value is positive. If not possible, returns false.
Source§

fn is_sign_negative(&self) -> bool

Returns whether the value is negative. If not possible, returns false.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,