Struct Label

Source
pub struct Label(/* private fields */);
Expand description

A styled string that does not contain any '\n' and implements Element and Cell.

Implementations§

Source§

impl Label

Source

pub fn new(s: &str) -> Self

Create a new label.

Source

pub fn blank() -> Self

Create a blank label.

Source

pub fn is_blank(&self) -> bool

Is this label empty.

Source

pub fn content(&self) -> &str

Get unstyled content.

Source

pub fn space() -> Self

Create a single space label

Source

pub fn boxed(self) -> Box<dyn Element>

Box the label.

Source

pub fn fg(self, color: Color) -> Self

Color the label’s foreground.

Source

pub fn bg(self, color: Color) -> Self

Color the label’s background.

Source

pub fn style(self, style: Style) -> Self

Style a label.

Source

pub fn paint(&self) -> &Paint<String>

Get inner paint object.

Source

pub fn filled(self, color: Color) -> Filled<Self>

Return a filled cell from this label.

Source

pub fn to_line(self) -> Line

Wrap into a line.

Trait Implementations§

Source§

impl Cell for Label

Source§

type Padded = Label

Type after padding.
Source§

type Truncated = Label

Type after truncation.
Source§

fn background(&self) -> Color

Background color of cell.
Source§

fn pad(&self, width: usize) -> Self::Padded

Pad the cell so that it is the given width, while keeping the content left-aligned.
Source§

fn truncate(&self, width: usize, delim: &str) -> Self::Truncated

Truncate cell if longer than given width. Shows the delimiter if truncated.
Source§

fn width(&self) -> usize

Cell display width in number of terminal columns.
Source§

impl Clone for Label

Source§

fn clone(&self) -> Label

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 Debug for Label

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Label

Source§

fn default() -> Label

Returns the “default value” for a type. Read more
Source§

impl Display for Label

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Element for Label

Source§

fn size(&self, _parent: Constraint) -> Size

Get the size of the element, in rows and columns.
Source§

fn render(&self, _parent: Constraint) -> Vec<Line>

Render the element as lines of text that can be printed.
Source§

fn columns(&self, parent: Constraint) -> usize

Get the number of columns occupied by this element.
Source§

fn rows(&self, parent: Constraint) -> usize

Get the number of rows occupied by this element.
Source§

fn print(&self)

Print this element to stdout.
Source§

fn write(&self, constraints: Constraint) -> Result<()>
where Self: Sized,

Write using the given constraints to stdout.
Source§

fn display(&self, constraints: Constraint) -> String

Return a string representation of this element.
Source§

impl From<&str> for Label

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl<D: Display> From<Paint<D>> for Label

Source§

fn from(paint: Paint<D>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Label

Source§

fn from(value: String) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for Label

§

impl RefUnwindSafe for Label

§

impl Send for Label

§

impl Sync for Label

§

impl Unpin for Label

§

impl UnwindSafe for Label

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,