Skip to main content

ViewCssExt

Trait ViewCssExt 

Source
pub trait ViewCssExt: Decorators + Sized {
    // Provided methods
    fn css(
        self,
        sheet: &Stylesheet,
        element: &str,
        classes: &[&str],
    ) -> Self::DV { ... }
    fn css_in(
        self,
        sheet: &Stylesheet,
        target: Node<'_>,
        ancestors: &[Node<'_>],
        prev_siblings: &[Node<'_>],
    ) -> Self::DV { ... }
}
Expand description

Extension trait that consumes a Stylesheet and applies its resolved properties — base plus every supported pseudo-state — to a floem view in one call.

Two entry points are provided:

  • .css(sheet, element, classes) — flat call for top-level views with no combinator context. Builds a Node internally and calls .css_in with empty ancestor / sibling slices.

  • .css_in(sheet, target, ancestors, prev_siblings) — context-aware call for views that live inside a hierarchy. Enables descendant ( ), child (>), adjacent-sibling (+), and general-sibling (~) selectors to match.

A CssContext builder is deliberately not introduced here: the two-method surface keeps the API minimal. If a third variant is needed in the future (e.g. per-property filtering or lazy resolution), CssContext is the right abstraction to reach for then.

Sealed by the blanket impl. Downstream crates cannot add their own impl ViewCssExt for SomeWrapper because the orphan rule + the blanket impl would conflict. Consumers needing custom property application should write a free function or their own extension trait that delegates to this one.

Provided Methods§

Source

fn css(self, sheet: &Stylesheet, element: &str, classes: &[&str]) -> Self::DV

Resolve and apply styles for element with classes, no combinator context. Equivalent to .css_in(sheet, Node { element, classes }, &[], &[]).

Source

fn css_in( self, sheet: &Stylesheet, target: Node<'_>, ancestors: &[Node<'_>], prev_siblings: &[Node<'_>], ) -> Self::DV

Resolve and apply styles for target inside a given tree context. ancestors is root→parent (exclusive of target); prev_siblings is oldest→immediately-preceding sibling (exclusive of target).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§