StyleSheet

Struct StyleSheet 

Source
pub struct StyleSheet { /* private fields */ }
Expand description

Represents a CSS style sheet with parsed rules and declarations.

§Fields

  • rules: A collection of selectors and their corresponding declarations.

§Example

let css = ".example { color: red; }";
let stylesheet = cssengine::StyleSheet::from_css(css);

Implementations§

Source§

impl StyleSheet

Source

pub const fn new_const() -> Self

Source

pub fn from_css<'a>(input: &'a str) -> Self

Creates a StyleSheet from a CSS input string.

§Parameters
  • input: The CSS input string.
§Returns

A new StyleSheet instance containing the parsed rules.

§Example
let css = ".example { color: red; }";
let stylesheet = cssengine::StyleSheet::from_css(css);
Source

pub fn get_styles( &mut self, selector: impl AsRef<str>, ) -> SmallVec<[(Option<PseudoClass>, SmallVec<[Declaration; 32]>); 4]>

Retrieves the styles for a given selector.

§Parameters
  • selector: A CSS selector (e.g., .class, #id).
§Returns
  • Some(SmallVec<Declaration>) if styles exist for the selector.
  • None if no matching styles are found.
§Example
let css = ".example { color: red; }";
let mut stylesheet = cssengine::StyleSheet::from_css(css);
if let Some(styles) = stylesheet.get_styles(".example") {
    println!("Styles: {:?}", styles);
}

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> 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, 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.