Skip to main content

RenderedSegment

Struct RenderedSegment 

Source
#[non_exhaustive]
pub struct RenderedSegment { /* private fields */ }
Expand description

Output of a successful segment render.

Fields are pub(crate) so the engine can read them directly; external callers go through the constructors and accessors so the width == text_width(text) invariant can’t desync via a mutable text. #[non_exhaustive] keeps future additions SemVer-safe.

Implementations§

Source§

impl RenderedSegment

Source

pub fn new(text: impl Into<String>) -> Self

Build a rendered segment from text, auto-computing its cell width. Use Self::with_separator when the segment wants to override its default right-separator for this boundary, and Self::with_role / Self::with_style to attach a theme role or full style.

Source

pub fn with_separator(text: impl Into<String>, separator: Separator) -> Self

Source

pub fn with_role(self, role: Role) -> Self

Chainable setter for the segment’s theme role. The layout engine resolves the role against the active theme + terminal capability at render time; no ANSI bytes land in text.

Preserves any decorations previously set by Self::with_style. Pair with with_style carefully: .with_style(s).with_role(r) keeps s’s bold/fg/etc. and swaps role, whereas .with_role(r).with_style(s) wholesale-replaces everything.

Source

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

Chainable setter for the full style (role + decorations). Wholesale-replaces the current style; use Self::with_role when you want to preserve decorations and swap only the role.

Source

pub fn style(&self) -> &Style

Style this segment wants applied when the layout emits it.

Source

pub fn text(&self) -> &str

The rendered text.

Source

pub fn width(&self) -> u16

Cell width of the rendered text.

Source

pub fn right_separator(&self) -> Option<&Separator>

Separator this render prefers on its right edge, if any. None means “fall back to the segment’s default separator.”

Trait Implementations§

Source§

impl Clone for RenderedSegment

Source§

fn clone(&self) -> RenderedSegment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderedSegment

Source§

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

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

impl PartialEq for RenderedSegment

Source§

fn eq(&self, other: &RenderedSegment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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.
Source§

impl Eq for RenderedSegment

Source§

impl StructuralPartialEq for RenderedSegment

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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, 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.