Trait FormattableTextDyn

Source
pub trait FormattableTextDyn: Debug {
    // Required methods
    fn clone_boxed(&self) -> Box<dyn FormattableTextDyn>;
    fn str_len(&self) -> usize;
    fn as_str(&self) -> &str;
    fn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken> ;
    fn effect_tokens(&self) -> &[Effect<()>];
}
Expand description

Text, optionally with formatting data

This is an object-safe version of the FormattableText trait (i.e. dyn FormattableTextDyn is a valid type).

This trait is auto-implemented for every implementation of FormattableText. The type &dyn FormattableTextDyn implements FormattableText. Implement either this or (preferably) FormattableText, not both.

Required Methods§

Source

fn clone_boxed(&self) -> Box<dyn FormattableTextDyn>

Produce a boxed clone of self

Source

fn str_len(&self) -> usize

Length of text

Source

fn as_str(&self) -> &str

Access whole text as contiguous str

Source

fn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken>

Construct an iterator over formatting items

It is expected that FontToken::start of yielded items is strictly increasing; if not, formatting may not be applied correctly.

The default font size (dpem) is passed as a reference.

For plain text this iterator will be empty.

Source

fn effect_tokens(&self) -> &[Effect<()>]

Get the sequence of effect tokens

This method has some limitations: (1) it may only return a reference to an existing sequence, (2) effect tokens cannot be generated dependent on input state, and (3) it does not incorporate color information. For most uses it should still be sufficient, but for other cases it may be preferable not to use this method (use a dummy implementation returning &[] and use inherent methods on the text object via Text::text).

Trait Implementations§

Source§

impl Clone for Box<dyn FormattableTextDyn>

Source§

fn clone(&self) -> Box<dyn FormattableTextDyn>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'t> FormattableText for &'t dyn FormattableTextDyn

Source§

type FontTokenIter<'a> = OwningVecIter<FontToken> where &'t dyn FormattableTextDyn: 'a

Source§

fn str_len(&self) -> usize

Length of text Read more
Source§

fn as_str(&self) -> &str

Access whole text as contiguous str
Source§

fn font_tokens(&self, dpem: f32) -> OwningVecIter<FontToken>

Construct an iterator over formatting items Read more
Source§

fn effect_tokens(&self) -> &[Effect<()>]

Get the sequence of effect tokens Read more
Source§

impl<'t> PartialEq for &'t dyn FormattableTextDyn

References to FormattableTextDyn always compare unequal

Source§

fn eq(&self, _: &&'t dyn FormattableTextDyn) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Implementors§

Source§

impl<F> FormattableTextDyn for F
where F: FormattableText + Clone + 'static,