Enum DimensionUnit
pub enum DimensionUnit {
Show 65 variants
Unknown = 0,
Cap = 1,
Ch = 2,
Cm = 3,
Cqb = 4,
Cqh = 5,
Cqi = 6,
Cqmax = 7,
Cqmin = 8,
Cqw = 9,
Db = 10,
Deg = 11,
Dpcm = 12,
Dpi = 13,
Dppx = 14,
Dvb = 15,
Dvh = 16,
Dvi = 17,
Dvmax = 18,
Dvmin = 19,
Dvw = 20,
Em = 21,
Ex = 22,
Fr = 23,
Grad = 24,
Hz = 25,
Ic = 26,
In = 27,
Khz = 28,
Lh = 29,
Lvb = 30,
Lvh = 31,
Lvi = 32,
Lvmax = 33,
Lvmin = 34,
Lvw = 35,
Mm = 36,
Ms = 37,
Pc = 38,
Percent = 39,
Pt = 40,
Px = 41,
Q = 42,
Rad = 43,
Rcap = 44,
Rch = 45,
Rem = 46,
Rex = 47,
Ric = 48,
Rlh = 49,
S = 50,
Svb = 51,
Svh = 52,
Svi = 53,
Svmax = 54,
Svmin = 55,
Svw = 56,
Turn = 57,
Vb = 58,
Vh = 59,
Vi = 60,
Vmax = 61,
Vmin = 62,
Vw = 63,
X = 64,
}
Expand description
Represents a Kind::Dimension’s unit, if it is “known”: defined by the CSS grammar.
In order to more efficiently lex CSS, the known dimension units are encoded into Tokens. This avoids the need for subsequent downstream passes to consult the underlying string data to establish what kind of dimension unit the Kind::Dimension represents.
This enum captures all known and defined units per the CSS specifications. Custom units (e.g. those beginning with a
double dash (--
)), unknown units, or units using escape characters will all be represented using the
DimensionUnit::Unknown variant which means the underlying &str
must be consulted.
§Example
use css_lexer::*;
let mut lexer = Lexer::new("10px");
{
let token = lexer.advance();
assert_eq!(token, Kind::Dimension);
assert_eq!(token, DimensionUnit::Px);
let unit = token.dimension_unit();
let str: &'static str = unit.into();
assert_eq!(str, "px");
}
Variants§
Unknown = 0
Cap = 1
Ch = 2
Cm = 3
Cqb = 4
Cqh = 5
Cqi = 6
Cqmax = 7
Cqmin = 8
Cqw = 9
Db = 10
Deg = 11
Dpcm = 12
Dpi = 13
Dppx = 14
Dvb = 15
Dvh = 16
Dvi = 17
Dvmax = 18
Dvmin = 19
Dvw = 20
Em = 21
Ex = 22
Fr = 23
Grad = 24
Hz = 25
Ic = 26
In = 27
Khz = 28
Lh = 29
Lvb = 30
Lvh = 31
Lvi = 32
Lvmax = 33
Lvmin = 34
Lvw = 35
Mm = 36
Ms = 37
Pc = 38
Percent = 39
Pt = 40
Px = 41
Q = 42
Rad = 43
Rcap = 44
Rch = 45
Rem = 46
Rex = 47
Ric = 48
Rlh = 49
S = 50
Svb = 51
Svh = 52
Svi = 53
Svmax = 54
Svmin = 55
Svw = 56
Turn = 57
Vb = 58
Vh = 59
Vi = 60
Vmax = 61
Vmin = 62
Vw = 63
X = 64
Implementations§
Trait Implementations§
§impl Clone for DimensionUnit
impl Clone for DimensionUnit
§fn clone(&self) -> DimensionUnit
fn clone(&self) -> DimensionUnit
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more§impl Debug for DimensionUnit
impl Debug for DimensionUnit
§impl Default for DimensionUnit
impl Default for DimensionUnit
§fn default() -> DimensionUnit
fn default() -> DimensionUnit
Returns the “default value” for a type. Read more
§impl From<&str> for DimensionUnit
impl From<&str> for DimensionUnit
§fn from(value: &str) -> DimensionUnit
fn from(value: &str) -> DimensionUnit
Converts to this type from the input type.
§impl From<Cursor> for DimensionUnit
impl From<Cursor> for DimensionUnit
§fn from(cursor: Cursor) -> DimensionUnit
fn from(cursor: Cursor) -> DimensionUnit
Converts to this type from the input type.
§impl From<DimensionUnit> for &'static str
impl From<DimensionUnit> for &'static str
§fn from(value: DimensionUnit) -> &'static str
fn from(value: DimensionUnit) -> &'static str
Converts to this type from the input type.
§impl From<Token> for DimensionUnit
impl From<Token> for DimensionUnit
§fn from(token: Token) -> DimensionUnit
fn from(token: Token) -> DimensionUnit
Converts to this type from the input type.
§impl From<u8> for DimensionUnit
impl From<u8> for DimensionUnit
§fn from(value: u8) -> DimensionUnit
fn from(value: u8) -> DimensionUnit
Converts to this type from the input type.
§impl Hash for DimensionUnit
impl Hash for DimensionUnit
§impl Ord for DimensionUnit
impl Ord for DimensionUnit
§impl PartialEq<DimensionUnit> for &Cursor
impl PartialEq<DimensionUnit> for &Cursor
§impl PartialEq<DimensionUnit> for Cursor
impl PartialEq<DimensionUnit> for Cursor
§impl PartialEq<DimensionUnit> for Token
impl PartialEq<DimensionUnit> for Token
§impl PartialEq for DimensionUnit
impl PartialEq for DimensionUnit
§impl PartialOrd for DimensionUnit
impl PartialOrd for DimensionUnit
§impl Serialize for DimensionUnit
impl Serialize for DimensionUnit
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for DimensionUnit
impl Eq for DimensionUnit
impl StructuralPartialEq for DimensionUnit
Auto Trait Implementations§
impl Freeze for DimensionUnit
impl RefUnwindSafe for DimensionUnit
impl Send for DimensionUnit
impl Sync for DimensionUnit
impl Unpin for DimensionUnit
impl UnwindSafe for DimensionUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Set the foreground color generically Read more
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Set the background color generically. Read more
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Change the background color to magenta
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Change the foreground color to the terminal default
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Change the background color to the terminal default
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Change the foreground color to bright black
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Change the background color to bright black
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Change the foreground color to bright red
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Change the background color to bright red
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Change the foreground color to bright green
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Change the background color to bright green
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Change the foreground color to bright yellow
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Change the background color to bright yellow
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Change the foreground color to bright blue
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Change the background color to bright blue
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright magenta
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright magenta
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Change the foreground color to bright purple
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Change the background color to bright purple
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Change the foreground color to bright cyan
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Change the background color to bright cyan
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Change the foreground color to bright white
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Change the background color to bright white
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Make the text blink (but fast!)
Hide the text
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Cross out the text
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either [
OwoColorize::fg
] or
a color-specific method, such as [OwoColorize::green
], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either [
OwoColorize::bg
] or
a color-specific method, such as [OwoColorize::on_yellow
], Read more§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the foreground color to a specific RGB value.
§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Set the background color to a specific RGB value.
§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Sets the foreground color to an RGB value.
§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Sets the background color to an RGB value.