Skip to main content

TruncateStrategy

Enum TruncateStrategy 

Source
pub enum TruncateStrategy {
    Middle {
        min_head_items: usize,
        min_tail_items: usize,
        ellipsis: String,
    },
    Start {
        min_tail_items: usize,
        ellipsis: String,
    },
    End {
        min_head_items: usize,
        ellipsis: String,
    },
    ShortenNames {
        max_abbrev_len: usize,
        preserve_tail_items: usize,
        ellipsis: String,
    },
    None,
}
Expand description

Strategy determining how breadcrumb segments are collapsed when overflowing horizontal bounds.

Variants§

§

Middle

Collapses intermediate ancestor segments into an ellipsis while preserving the root ancestor(s) and deepest active segment(s).

Example: Home ❯ ... ❯ src ❯ sparkline.rs

Fields

§min_head_items: usize

Minimum number of root/head segments to preserve on the left.

§min_tail_items: usize

Minimum number of leaf/tail segments to preserve on the right.

§ellipsis: String

The ellipsis indicator string (default "...").

§

Start

Collapses leftmost ancestor segments into an ellipsis while preserving the deepest active leaf segments.

Example: ... ❯ src ❯ sparkline.rs

Fields

§min_tail_items: usize

Minimum number of leaf/tail segments to preserve on the right.

§ellipsis: String

The ellipsis indicator string (default "...").

§

End

Collapses deepest leaf segments into an ellipsis while preserving root ancestor segments (left-to-right priority).

Example: Home ❯ Projects ❯ ...

Fields

§min_head_items: usize

Minimum number of root/head segments to preserve on the left.

§ellipsis: String

The ellipsis indicator string (default "...").

§

ShortenNames

Progressively abbreviates ancestor item labels to their leading characters before collapsing them into an ellipsis if space is still constrained.

Example: H ❯ P ❯ ratatui ❯ src ❯ sparkline.rs

Fields

§max_abbrev_len: usize

Target abbreviation character length for shortened ancestor labels (default 1).

§preserve_tail_items: usize

Number of deepest tail segments to leave unshortened.

§ellipsis: String

Fallback ellipsis indicator if the trail still overflows after shortening.

§

None

Performs no smart condensation or ellipsis substitution; segments are clipped at the boundary.

Implementations§

Source§

impl TruncateStrategy

Source

pub fn middle() -> Self

Creates a default Middle strategy preserving 1 root item, 2 tail items, and "..." ellipsis.

Source

pub fn middle_with( min_head_items: usize, min_tail_items: usize, ellipsis: impl Into<String>, ) -> Self

Creates a customized Middle strategy.

Source

pub fn start() -> Self

Creates a default Start strategy preserving 2 tail items and "..." ellipsis.

Source

pub fn start_with(min_tail_items: usize, ellipsis: impl Into<String>) -> Self

Creates a customized Start strategy.

Source

pub fn end() -> Self

Creates a default End strategy preserving 1 head item and "..." ellipsis.

Source

pub fn end_with(min_head_items: usize, ellipsis: impl Into<String>) -> Self

Creates a customized End strategy.

Source

pub fn shorten_names() -> Self

Creates a default ShortenNames strategy abbreviating ancestors to 1 character, preserving 2 tail items, and falling back to "...".

Source

pub fn shorten_names_with( max_abbrev_len: usize, preserve_tail_items: usize, ellipsis: impl Into<String>, ) -> Self

Creates a customized ShortenNames strategy.

Source

pub fn none() -> Self

Creates a None strategy that performs no truncation or ellipsis insertion.

Trait Implementations§

Source§

impl Clone for TruncateStrategy

Source§

fn clone(&self) -> TruncateStrategy

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 TruncateStrategy

Source§

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

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

impl Default for TruncateStrategy

Source§

fn default() -> Self

Defaults to TruncateStrategy::Middle with 1 head item, 2 tail items, and ... ellipsis.

Source§

impl Eq for TruncateStrategy

Source§

impl PartialEq for TruncateStrategy

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TruncateStrategy

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<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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.