pub struct Styled<C: Display> { /* private fields */ }Expand description
A value that associates some content with a specific style.
Implementations§
Source§impl<C: Display> Styled<C>
impl<C: Display> Styled<C>
Sourcepub const fn new(content: C) -> Self
pub const fn new(content: C) -> Self
Creates a new Styled<C> value with the given content and empty style.
Sourcepub const fn get_content(&self) -> &C
pub const fn get_content(&self) -> &C
Gets a reference to the enclosed content.
Sourcepub const fn with_content<C2: Display>(&self, content: C2) -> Styled<C2>
pub const fn with_content<C2: Display>(&self, content: C2) -> Styled<C2>
Returns a new Styled<C2> value with the same style and the given content.
Sourcepub fn into_content(self) -> C
pub fn into_content(self) -> C
Consumes the Styled<C> value and returns the enclosed content.
Sourcepub fn with_style(self, style: Style) -> Styled<C>
pub fn with_style(self, style: Style) -> Styled<C>
Returns a new Styled<C> value with the same content and the given style.
Sourcepub fn underline(self) -> Styled<C>
pub fn underline(self) -> Styled<C>
An alias for Self::solid_underline().
Sourcepub fn solid_underline(self) -> Styled<C>
pub fn solid_underline(self) -> Styled<C>
Sets the solid underline effect.
Sourcepub fn curly_underline(self) -> Styled<C>
pub fn curly_underline(self) -> Styled<C>
Sets the curly underline effect.
Sourcepub fn dotted_underline(self) -> Styled<C>
pub fn dotted_underline(self) -> Styled<C>
Sets the dotted underline effect.
Sourcepub fn dashed_underline(self) -> Styled<C>
pub fn dashed_underline(self) -> Styled<C>
Sets the dashed underline effect.
Sourcepub fn strikethrough(self) -> Styled<C>
pub fn strikethrough(self) -> Styled<C>
Sets the strikethrough effect.
Sourcepub fn double_underline(self) -> Styled<C>
pub fn double_underline(self) -> Styled<C>
Sets the double underline effect.
Sourcepub fn underline_effect(self, underline_effect: UnderlineEffect) -> Styled<C>
pub fn underline_effect(self, underline_effect: UnderlineEffect) -> Styled<C>
Sets the underline effect.
Sourcepub fn underline_color(self, color: impl Into<Color>) -> Styled<C>
pub fn underline_color(self, color: impl Into<Color>) -> Styled<C>
Sets the underline color.
Sourcepub fn color(self, targeted_color: impl Into<TargetedColor>) -> Styled<C>
pub fn color(self, targeted_color: impl Into<TargetedColor>) -> Styled<C>
Sets the given color in a target.
Sourcepub fn add(self, element: impl StylingElement<Styled<C>>) -> Styled<C>
pub fn add(self, element: impl StylingElement<Styled<C>>) -> Styled<C>
Adds the given element to the style.
Sourcepub fn set_effect(self, effect: impl Into<Effect>, value: bool) -> Self
pub fn set_effect(self, effect: impl Into<Effect>, value: bool) -> Self
Sets the given effect to the specified value.
Sourcepub fn get_effect(&self, effect: impl Into<Effect>) -> bool
pub fn get_effect(&self, effect: impl Into<Effect>) -> bool
Gets whether the given effect is set.
Sourcepub fn get_effects(&self) -> GetEffects ⓘ
pub fn get_effects(&self) -> GetEffects ⓘ
Returns an iterator over the effects that are currently set.
Sourcepub fn set_underline_effect(
self,
underline_effect: Option<UnderlineEffect>,
) -> Self
pub fn set_underline_effect( self, underline_effect: Option<UnderlineEffect>, ) -> Self
Sets the underline effect.
Sourcepub fn get_underline_effect(&self) -> Option<UnderlineEffect>
pub fn get_underline_effect(&self) -> Option<UnderlineEffect>
Gets the underline effect.
Sourcepub fn set_color(
self,
target: ColorTarget,
color: Option<impl Into<Color>>,
) -> Self
pub fn set_color( self, target: ColorTarget, color: Option<impl Into<Color>>, ) -> Self
Sets the color for the given color target.
To clear the color for some color target, the color type must be specified in the None value.
To help with that, the Color::none() method can be used:
styled.set_color(ColorTarget::Foreground, None::<Color>);
// or
styled.set_color(ColorTarget::Foreground, Color::none());Sourcepub fn get_color(&self, target: ColorTarget) -> Option<Color>
pub fn get_color(&self, target: ColorTarget) -> Option<Color>
Gets the color for the given color target.
Sourcepub fn set<A: StylingAttribute<Self>>(self, attr: A, value: A::Value) -> Self
pub fn set<A: StylingAttribute<Self>>(self, attr: A, value: A::Value) -> Self
Sets the given attribute to the specified value.
Sourcepub fn get<A: StylingAttribute<Self>>(&self, attr: A) -> A::Value
pub fn get<A: StylingAttribute<Self>>(&self, attr: A) -> A::Value
Gets the value of the given attribute.
Sourcepub fn remove<A: StylingAttribute<Self>>(self, attr: A) -> Self
pub fn remove<A: StylingAttribute<Self>>(self, attr: A) -> Self
Clears the given attribute.