pub struct CheckedDeclaration { /* private fields */ }Expand description
An owned CSS declaration whose property and value grammar were checked together.
The representation is private so a property name cannot be separated from its checked value
and recombined with another value. Construction is restricted to crate-owned boundaries that
pair a validated name with a sealed crate::CheckedCssValue grammar.
Different checked grammars and properties erase into the same storable type:
use leptos_css::{
CheckedDeclaration, CssColor, Padding, css_custom_property, px, rgb,
property::{ColorProperty, PaddingProperty},
};
css_custom_property!(ACCENT: CssColor = "--accent");
let declarations: Vec<CheckedDeclaration> = vec![
PaddingProperty.declare(Padding::all(px(16))),
ColorProperty.declare(rgb(255, 0, 0)),
ACCENT.declare(rgb(0, 0, 255)),
];
assert_eq!(declarations[0].property_name(), "padding");Its private constructor prevents unchecked property/value recombination:
ⓘ
use std::borrow::Cow;
use leptos_css::{CheckedDeclaration, rgb};
let _ = CheckedDeclaration::new(Cow::Borrowed("padding"), rgb(255, 0, 0));Implementations§
Source§impl CheckedDeclaration
impl CheckedDeclaration
Sourcepub fn property_name(&self) -> &str
pub fn property_name(&self) -> &str
Return the checked CSS property name.
Sourcepub fn write_declaration_to(&self, output: &mut String)
pub fn write_declaration_to(&self, output: &mut String)
Append the complete property:value; declaration to a string buffer.
Sourcepub fn into_attribute(self) -> impl Attribute
pub fn into_attribute(self) -> impl Attribute
Convert this declaration into a spreadable Leptos style attribute.
Trait Implementations§
Source§impl Clone for CheckedDeclaration
impl Clone for CheckedDeclaration
Source§impl Debug for CheckedDeclaration
impl Debug for CheckedDeclaration
impl Eq for CheckedDeclaration
Source§impl IntoStyle for CheckedDeclaration
impl IntoStyle for CheckedDeclaration
Source§type AsyncOutput = CheckedDeclaration
type AsyncOutput = CheckedDeclaration
The type after all async data have resolved.
Source§type State = (CssStyleDeclaration, CheckedDeclaration)
type State = (CssStyleDeclaration, CheckedDeclaration)
The view state retained between building and rebuilding.
Source§type Cloneable = CheckedDeclaration
type Cloneable = CheckedDeclaration
An equivalent value that can be cloned.
Source§type CloneableOwned = CheckedDeclaration
type CloneableOwned = CheckedDeclaration
An equivalent value that can be cloned and is
'static.Source§fn hydrate<const FROM_SERVER: bool>(self, el: &Element) -> Self::State
fn hydrate<const FROM_SERVER: bool>(self, el: &Element) -> Self::State
Adds interactivity as necessary, given DOM nodes that were created from HTML that has
either been rendered on the server, or cloned for a
<template>.Source§fn build(self, el: &Element) -> Self::State
fn build(self, el: &Element) -> Self::State
Adds this style to the element during client-side rendering.
Source§fn into_cloneable(self) -> Self::Cloneable
fn into_cloneable(self) -> Self::Cloneable
Converts this to a cloneable type.
Source§fn into_cloneable_owned(self) -> Self::CloneableOwned
fn into_cloneable_owned(self) -> Self::CloneableOwned
Converts this to a cloneable, owned type.
Source§fn dry_resolve(&mut self)
fn dry_resolve(&mut self)
“Runs” the attribute without other side effects. For primitive types, this is a no-op. For
reactive types, this can be used to gather data about reactivity or about asynchronous data
that needs to be loaded.
Source§async fn resolve(self) -> Self::AsyncOutput
async fn resolve(self) -> Self::AsyncOutput
“Resolves” this into a type that is not waiting for any asynchronous data.
Source§impl PartialEq for CheckedDeclaration
impl PartialEq for CheckedDeclaration
impl StructuralPartialEq for CheckedDeclaration
Auto Trait Implementations§
impl Freeze for CheckedDeclaration
impl RefUnwindSafe for CheckedDeclaration
impl Send for CheckedDeclaration
impl Sync for CheckedDeclaration
impl Unpin for CheckedDeclaration
impl UnsafeUnpin for CheckedDeclaration
impl UnwindSafe for CheckedDeclaration
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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 moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.