pub struct CSSRule {
pub selector: String,
pub declarations: Vec<CSSDeclaration>,
pub nested_rules: Vec<CSSRule>,
pub media_query: Option<String>,
pub specificity: u32,
pub position: Option<SourcePosition>,
}Expand description
CSS rule representation
Fields§
§selector: StringRule selector (e.g., “.class”, “#id”, “div”)
declarations: Vec<CSSDeclaration>CSS declarations
nested_rules: Vec<CSSRule>Nested rules (for complex selectors)
media_query: Option<String>Media query (for responsive rules)
specificity: u32Rule specificity
position: Option<SourcePosition>Source position
Implementations§
Source§impl CSSRule
CSS specificity calculation
impl CSSRule
CSS specificity calculation
Sourcepub fn calculate_specificity(&self) -> u32
pub fn calculate_specificity(&self) -> u32
Calculate CSS specificity
Sourcepub fn matches_selector(&self, target_selector: &str) -> bool
pub fn matches_selector(&self, target_selector: &str) -> bool
Check if rule matches a selector
Sourcepub fn add_declaration(
&mut self,
property: String,
value: String,
important: bool,
)
pub fn add_declaration( &mut self, property: String, value: String, important: bool, )
Add a declaration to the rule
Sourcepub fn remove_declaration(&mut self, property: &str)
pub fn remove_declaration(&mut self, property: &str)
Remove a declaration by property name
Sourcepub fn get_declaration(&self, property: &str) -> Option<&CSSDeclaration>
pub fn get_declaration(&self, property: &str) -> Option<&CSSDeclaration>
Get a declaration by property name
Sourcepub fn has_property(&self, property: &str) -> bool
pub fn has_property(&self, property: &str) -> bool
Check if rule has a specific property
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CSSRule
impl<'de> Deserialize<'de> for CSSRule
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>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for CSSRule
Auto Trait Implementations§
impl Freeze for CSSRule
impl RefUnwindSafe for CSSRule
impl Send for CSSRule
impl Sync for CSSRule
impl Unpin for CSSRule
impl UnwindSafe for CSSRule
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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