Skip to main content

StyleAccess

Struct StyleAccess 

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

Batched style builder — collects declarations, flushes in ONE write on drop.

Like JavaScript’s element.style but batched: setting N properties costs one lock acquisition, not N. Chrome does the same — style mutations are batched within a microtask.

Implementations§

Source§

impl StyleAccess

Source

pub fn display(&mut self, value: Display) -> &mut Self

Source

pub fn color(&mut self, value: impl Into<AbsoluteColor>) -> &mut Self

Source

pub fn background_color(&mut self, value: impl Into<AbsoluteColor>) -> &mut Self

Source

pub fn width(&mut self, value: impl Into<Size>) -> &mut Self

Source

pub fn height(&mut self, value: impl Into<Size>) -> &mut Self

Source

pub fn min_width(&mut self, value: impl Into<Size>) -> &mut Self

Source

pub fn min_height(&mut self, value: impl Into<Size>) -> &mut Self

Source

pub fn margin_top(&mut self, value: impl Into<Margin>) -> &mut Self

Source

pub fn margin_right(&mut self, value: impl Into<Margin>) -> &mut Self

Source

pub fn margin_bottom(&mut self, value: impl Into<Margin>) -> &mut Self

Source

pub fn margin_left(&mut self, value: impl Into<Margin>) -> &mut Self

Source

pub fn margin(&mut self, value: impl Into<Margin>) -> &mut Self

Source

pub fn padding_top( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn padding_right( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn padding_bottom( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn padding_left( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn padding( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn position(&mut self, value: PositionProperty) -> &mut Self

Source

pub fn font_size(&mut self, value: FontSize) -> &mut Self

Source

pub fn font_weight(&mut self, value: FontWeight) -> &mut Self

Source

pub fn font_family(&mut self, name: &str) -> &mut Self

Set font-family from a name string (e.g., “Cairo”, “Roboto”).

Chrome equivalent: setting element.style.fontFamily. Constructs a Stylo FontFamily with a single named family.

For multiple families or generics, use set_attribute("style", "font-family: ...").

Source

pub fn opacity(&mut self, value: Opacity) -> &mut Self

Source

pub fn flex_grow(&mut self, value: f32) -> &mut Self

Source

pub fn flex_shrink(&mut self, value: f32) -> &mut Self

Source

pub fn flex_basis(&mut self, value: impl Into<Size>) -> &mut Self

Source

pub fn gap( &mut self, value: impl Into<NonNegativeLengthPercentage>, ) -> &mut Self

Source

pub fn flex_direction(&mut self, value: T) -> &mut Self

Source

pub fn flex_wrap(&mut self, value: T) -> &mut Self

Source

pub fn flex_row(&mut self) -> &mut Self

display: flex; flex-direction: row

Source

pub fn flex_col(&mut self) -> &mut Self

display: flex; flex-direction: column

Source

pub fn align_items_center(&mut self) -> &mut Self

Source

pub fn align_items_start(&mut self) -> &mut Self

Source

pub fn align_items_end(&mut self) -> &mut Self

Source

pub fn align_items_stretch(&mut self) -> &mut Self

Source

pub fn justify_content_center(&mut self) -> &mut Self

Source

pub fn justify_content_start(&mut self) -> &mut Self

Source

pub fn justify_content_end(&mut self) -> &mut Self

Source

pub fn justify_content_between(&mut self) -> &mut Self

Source

pub fn border_radius( &mut self, v: impl Into<NonNegativeLengthPercentage> + Clone, ) -> &mut Self

Source

pub fn border_width( &mut self, v: impl Into<NonNegativeLengthPercentage> + Clone, ) -> &mut Self

Source

pub fn border_style(&mut self, v: BorderStyle) -> &mut Self

Source

pub fn border_color(&mut self, v: impl Into<AbsoluteColor>) -> &mut Self

Source

pub fn border_bottom_width_px(&mut self, v: f32) -> &mut Self

Source

pub fn border_bottom_style(&mut self, v: BorderStyle) -> &mut Self

Source

pub fn border_bottom_color(&mut self, v: impl Into<AbsoluteColor>) -> &mut Self

Source

pub fn border_right_width_px(&mut self, v: f32) -> &mut Self

Source

pub fn border_right_style(&mut self, v: BorderStyle) -> &mut Self

Source

pub fn border_right_color(&mut self, v: impl Into<AbsoluteColor>) -> &mut Self

Source

pub fn overflow_hidden(&mut self) -> &mut Self

Source

pub fn w(&mut self, v: impl Into<Size>) -> &mut Self

Short for width.

Source

pub fn h(&mut self, v: impl Into<Size>) -> &mut Self

Short for height.

Source

pub fn size(&mut self, v: impl Into<Size> + Clone) -> &mut Self

Width + height (square).

Source

pub fn bg(&mut self, v: impl Into<AbsoluteColor>) -> &mut Self

Short for background_color.

Source

pub fn flex(&mut self) -> &mut Self

display: flex.

Source

pub fn grid(&mut self) -> &mut Self

display: grid.

Source

pub fn block(&mut self) -> &mut Self

display: block.

Source

pub fn pad(&mut self, v: impl Into<NonNegativeLengthPercentage>) -> &mut Self

Short for padding (all 4).

Source

pub fn mar(&mut self, v: impl Into<Margin>) -> &mut Self

Short for margin (all 4).

Source

pub fn raw(&mut self, decl: PropertyDeclaration) -> &mut Self

Source

pub fn apply(&mut self)

Flush all pending declarations NOW. Not needed for chains — Drop flushes automatically at semicolon.

Trait Implementations§

Source§

impl Drop for StyleAccess

Auto-flush on drop — chains flush at the semicolon.

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,