pub trait StyleComponent: Any + RefUnwindSafe + UnwindSafe + Send + Sync + Debug + 'static {
    // Provided methods
    fn name() -> Name { ... }
    fn authority() -> Identifier { ... }
    fn inherited() -> bool { ... }
    fn merge(&mut self, other: &Self) { ... }
}
Expand description

A style component. Implementors can be stored within Style.

Deriving this trait

This trait can be derived. It can be customized using the style attribute with these parameters:

  • inherited: A boolean value, false by default.
  • name: An identifier. By default, the type’s name converted to snake case is used. For example, a type named StyleComponent would return Name::new(StyleComponent::authority(), "style_component").
  • authority: An identifier. By default, this is Identifier::private().
  • merge: An expression to evaluate when merging. self and other are defined. By default, components do not merge.

Provided Methods§

source

fn name() -> Name

The unique name of this style component.

This function returns a qualified name. The default implementation uses the type’s name converted to snake case. E.g., StyleCompoment becomes style_component, and StyleComponent::authority() for the authority.

source

fn authority() -> Identifier

Returns the authority of this component. By default, this returns Identifier::private().

source

fn inherited() -> bool

Returns whether the component should be inherited. Affects the behavior of Style::inherited_from

This provided imiplementation returns false.

source

fn merge(&mut self, other: &Self)

Merges self with other, if it makes sense to do so for this type. The default implementation does nothing, preserving the self value.

Implementors§