pub struct CssCustomProperty<T> { /* private fields */ }Expand description
A validated CSS custom property associated with one Rust value grammar.
The type parameter prevents ordinary checked code from using, for example, a color variable
as a size. The same CSS name must not be independently constructed with two different Rust
grammar types; conflicting handwritten or external declarations are outside this crate’s
checked boundary. Constructors are available only when T implements the sealed
CheckedCssValue marker.
Implementations§
Source§impl<T: CheckedCssValue> CssCustomProperty<T>
impl<T: CheckedCssValue> CssCustomProperty<T>
Sourcepub const fn from_static(name: &'static str) -> Self
pub const fn from_static(name: &'static str) -> Self
Construct a checked custom property from a static name.
This constructor is const and therefore suitable for module-level declarations. Prefer the
css_custom_property macro for compile-time-checked literals.
§Panics
Const evaluation fails if name is outside the checked identifier subset.
Sourcepub fn new(name: impl Into<Cow<'static, str>>) -> Self
pub fn new(name: impl Into<Cow<'static, str>>) -> Self
Construct a checked custom property.
§Panics
Panics if name is not in the checked custom-property identifier subset. Use
CssCustomProperty::try_new for runtime-derived names.
Sourcepub fn try_new(
name: impl Into<Cow<'static, str>>,
) -> Result<Self, InvalidCustomPropertyName>
pub fn try_new( name: impl Into<Cow<'static, str>>, ) -> Result<Self, InvalidCustomPropertyName>
Attempt to construct a checked custom property.
Sourcepub fn declare(
&self,
value: impl Into<DeclarationValue<T>>,
) -> CheckedDeclaration
pub fn declare( &self, value: impl Into<DeclarationValue<T>>, ) -> CheckedDeclaration
Assign a checked value to this custom property.
The value may be a literal of T or a typed crate::var reference with the same
grammar. Arbitrary custom-property token streams are intentionally unsupported.
Trait Implementations§
Source§impl<T> Clone for CssCustomProperty<T>
impl<T> Clone for CssCustomProperty<T>
Source§impl<T: Debug> Debug for CssCustomProperty<T>
impl<T: Debug> Debug for CssCustomProperty<T>
Source§impl<T: CheckedCssValue> Display for CssCustomProperty<T>
impl<T: CheckedCssValue> Display for CssCustomProperty<T>
impl<T: Eq> Eq for CssCustomProperty<T>
Source§impl<T: Hash> Hash for CssCustomProperty<T>
impl<T: Hash> Hash for CssCustomProperty<T>
Source§impl<T: PartialEq> PartialEq for CssCustomProperty<T>
impl<T: PartialEq> PartialEq for CssCustomProperty<T>
impl<T: PartialEq> StructuralPartialEq for CssCustomProperty<T>
Auto Trait Implementations§
impl<T> Freeze for CssCustomProperty<T>
impl<T> RefUnwindSafe for CssCustomProperty<T>
impl<T> Send for CssCustomProperty<T>
impl<T> Sync for CssCustomProperty<T>
impl<T> Unpin for CssCustomProperty<T>
impl<T> UnsafeUnpin for CssCustomProperty<T>
impl<T> UnwindSafe for CssCustomProperty<T>
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
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
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> ⓘ
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> ⓘ
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