Skip to main content

NodeRef

Struct NodeRef 

Source
pub struct NodeRef<'a> { /* private fields */ }
Expand description

A borrowed node: type_name, id, and classes are all &'a str / &'a [&'a str] borrows, so construction is zero-allocation (a compile-time guarantee when the source data is &'static).

Use this in the draw loop:

let node = NodeRef::new("Button").classes(&["primary"]).state(State::focus());
let computed = sheet.compute(&node, None);

Builder methods mirror OwnedNode’s (with_*) for easy migration, plus short classes/state setters.

Implementations§

Source§

impl<'a> NodeRef<'a>

Source

pub fn new(type_name: &'a str) -> Self

Borrow type_name. Zero-allocation.

Source

pub fn id(self, id: &'a str) -> Self

Set the id (borrowed). Zero-allocation.

Source

pub fn with_id(self, id: &'a str) -> Self

Alias for id, matching OwnedNode::with_id.

Source

pub fn classes(self, classes: &'a [&'a str]) -> Self

Set the class list (borrowed slice). Zero-allocation.

Source

pub fn with_classes(self, classes: &'a [&'a str]) -> Self

Alias for classes, matching OwnedNode::with_classes.

Source

pub fn state(self, state: State) -> Self

Set the pseudo-class state. Zero-allocation.

Source

pub fn with_state(self, state: State) -> Self

Alias for state, matching OwnedNode::with_state.

Source

pub fn position(self, position: Position) -> Self

Set the sibling position. Rarely needed in the draw loop.

Trait Implementations§

Source§

impl<'a> StyledNode for NodeRef<'a>

Source§

fn type_name(&self) -> &str

Element type name — matches a CSS type selector (e.g. "Button").
Source§

fn id(&self) -> Option<&str>

Element id — matches a CSS #id selector.
Source§

fn classes(&self) -> Classes<'_>

Class names — match CSS .class selectors. Read more
Source§

fn state(&self) -> State

Pseudo-class state — matches :focus / :disabled / etc.
Source§

fn position(&self) -> Position

Sibling position — for future :nth-child support. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for NodeRef<'a>

§

impl<'a> RefUnwindSafe for NodeRef<'a>

§

impl<'a> Send for NodeRef<'a>

§

impl<'a> Sync for NodeRef<'a>

§

impl<'a> Unpin for NodeRef<'a>

§

impl<'a> UnsafeUnpin for NodeRef<'a>

§

impl<'a> UnwindSafe for NodeRef<'a>

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