[][src]Struct ornament::Decorator

pub struct Decorator<F: Default> { /* fields omitted */ }

A helper type to build a Text instance.

It can be used in several manners.

  • Incremental, using a "current face" (*_face and append methods).
  • Immediate by setting face ranges directly (set method).
  • A combination of both.

Implementations

impl<F> Decorator<F> where
    F: Clone + Default + PartialEq
[src]

pub fn new() -> Decorator<F>[src]

Creates a new empty Decorator.

pub fn with_text(text: &str) -> Decorator<F>[src]

Creates a new Decorator initialized with text.

pub fn current_face(&self) -> &F[src]

Returns the current face. On init this value will be equivalent to F::default().

This face is mostly used by append which will assign the current face to the appended text.

pub fn set_face(&mut self, face: F) -> &mut Self[src]

Sets the current face.

This method is chainable.

pub fn reset_face(&mut self) -> &mut Self[src]

Resets the current face. This is equivalent to calling set_face with F::default().

This method is chainable.

pub fn append(&mut self, text: &str) -> &mut Self[src]

Appends text to the buffer and assigns it the current face.

This method is chainable.

pub fn set(&mut self, face: F, range: Range<usize>) -> &mut Self[src]

Assigns face to the given range. It overrides all faces previously assigned to this range.

This method is chainable.

pub fn build(&mut self) -> Text<F>[src]

Processes all face assignations and returns the corresponding Text.

Trait Implementations

impl<F> Default for Decorator<F> where
    F: Clone + Default + PartialEq
[src]

Auto Trait Implementations

impl<F> RefUnwindSafe for Decorator<F> where
    F: RefUnwindSafe

impl<F> Send for Decorator<F> where
    F: Send

impl<F> Sync for Decorator<F> where
    F: Sync

impl<F> Unpin for Decorator<F> where
    F: Unpin

impl<F> UnwindSafe for Decorator<F> where
    F: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.