Trait masonry::text2::TextStorage

source ·
pub trait TextStorage: 'static {
    // Required methods
    fn as_str(&self) -> &str;
    fn maybe_eq(&self, other: &Self) -> bool;

    // Provided methods
    fn add_attributes<'b>(
        &self,
        builder: RangedBuilder<'b, TextBrush, &'b str>
    ) -> RangedBuilder<'b, TextBrush, &'b str> { ... }
    fn links(&self) -> &[Link] { ... }
}
Expand description

Text which can be displayed.

Required Methods§

source

fn as_str(&self) -> &str

source

fn maybe_eq(&self, other: &Self) -> bool

Determines quickly whether two text objects have the same content.

To allow for faster checks, this method is allowed to return false negatives.

Provided Methods§

source

fn add_attributes<'b>( &self, builder: RangedBuilder<'b, TextBrush, &'b str> ) -> RangedBuilder<'b, TextBrush, &'b str>

If this TextStorage object manages style spans, it should implement this method and update the provided builder with its spans, as required.

This takes &self, as we needed to call Self::as_str to get the value stored in the RangedBuilder

Any additional Link attributes on this text.

If this TextStorage object manages link attributes, it should implement this method and return any attached Links.

Unlike other attributes, links are managed in Masonry, not in piet; as such they require a separate API.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl TextStorage for &'static str

source§

fn as_str(&self) -> &str

source§

fn maybe_eq(&self, other: &Self) -> bool

source§

impl TextStorage for String

source§

fn as_str(&self) -> &str

source§

fn maybe_eq(&self, other: &Self) -> bool

source§

impl TextStorage for Arc<String>

source§

fn as_str(&self) -> &str

source§

fn maybe_eq(&self, other: &Self) -> bool

Implementors§