Skip to main content

Box

Struct Box 

Source
pub struct Box {
Show 30 fields pub top_left: char, pub top: char, pub top_divider: char, pub top_right: char, pub head_left: char, pub head_vertical: char, pub head_right: char, pub head_row_left: char, pub head_row_horizontal: char, pub head_row_cross: char, pub head_row_right: char, pub mid_left: char, pub mid_vertical: char, pub mid_right: char, pub row_left: char, pub row_horizontal: char, pub row_cross: char, pub row_right: char, pub foot_row_left: char, pub foot_row_horizontal: char, pub foot_row_cross: char, pub foot_row_right: char, pub foot_left: char, pub foot_vertical: char, pub foot_right: char, pub bottom_left: char, pub bottom: char, pub bottom_divider: char, pub bottom_right: char, pub ascii: bool,
}
Expand description

A complete set of box-drawing characters for creating borders and tables.

The structure contains 32 characters arranged in 8 logical rows:

  • top: Top border (corners and dividers)
  • head: Header content row (vertical lines)
  • head_row: Header separator row
  • mid: Mid content row (vertical lines)
  • row: Body row separator
  • foot_row: Footer separator row
  • foot: Footer content row (vertical lines)
  • bottom: Bottom border (corners and dividers)

Fields§

§top_left: char

Top-left corner character.

§top: char

Top horizontal line character.

§top_divider: char

Top divider (T-junction pointing down).

§top_right: char

Top-right corner character.

§head_left: char

Left edge of header row.

§head_vertical: char

Vertical divider in header.

§head_right: char

Right edge of header row.

§head_row_left: char

Left edge of head row separator.

§head_row_horizontal: char

Horizontal line in head row separator.

§head_row_cross: char

Cross junction in head row separator.

§head_row_right: char

Right edge of head row separator.

§mid_left: char

Left edge of mid content row.

§mid_vertical: char

Vertical divider in mid section.

§mid_right: char

Right edge of mid content row.

§row_left: char

Left edge of row separator.

§row_horizontal: char

Horizontal line in row separator.

§row_cross: char

Cross junction in row separator.

§row_right: char

Right edge of row separator.

§foot_row_left: char

Left edge of foot row separator.

§foot_row_horizontal: char

Horizontal line in foot row separator.

§foot_row_cross: char

Cross junction in foot row separator.

§foot_row_right: char

Right edge of foot row separator.

§foot_left: char

Left edge of footer row.

§foot_vertical: char

Vertical divider in footer.

§foot_right: char

Right edge of footer row.

§bottom_left: char

Bottom-left corner character.

§bottom: char

Bottom horizontal line character.

§bottom_divider: char

Bottom divider (T-junction pointing up).

§bottom_right: char

Bottom-right corner character.

§ascii: bool

Whether this box uses ASCII characters only.

Implementations§

Source§

impl Box

Source

pub fn substitute(&self, legacy_windows: bool, ascii_only: bool) -> Box

Substitute this box for another if it won’t render due to platform issues.

§Arguments
  • legacy_windows - If true, substitute boxes that don’t render well with legacy Windows console (raster fonts).
  • ascii_only - If true, substitute non-ASCII boxes with ASCII equivalent.
§Returns

A compatible Box. For known box constants that need substitution, returns the appropriate fallback. For custom boxes, returns self unchanged unless ascii_only is true and self.ascii is false, in which case returns ASCII.

Source

pub fn get_plain_headed_box(&self) -> Box

If this box uses special characters for the header borders, return the equivalent box without special header characters.

§Returns

The equivalent plain-headed Box, or self if already plain. For custom boxes, returns self unchanged.

Source

pub fn get_top(&self, widths: &[usize]) -> String

Generate the top border of a box.

§Arguments
  • widths - Slice of column widths.
§Returns

A string representing the top border.

§Example
use rich_rs::r#box::SQUARE;

let top = SQUARE.get_top(&[5, 10, 5]);
assert_eq!(top, "┌─────┬──────────┬─────┐");
Source

pub fn get_row(&self, widths: &[usize], level: RowLevel, edge: bool) -> String

Generate a row separator line.

§Arguments
  • widths - Slice of column widths.
  • level - The type of row separator (Head, Row, Foot, or Mid).
  • edge - Whether to include edge characters (left and right borders).
§Returns

A string representing the row separator.

§Example
use rich_rs::r#box::{SQUARE, RowLevel};

let row = SQUARE.get_row(&[5, 10], RowLevel::Head, true);
assert_eq!(row, "├─────┼──────────┤");
Source

pub fn get_bottom(&self, widths: &[usize]) -> String

Generate the bottom border of a box.

§Arguments
  • widths - Slice of column widths.
§Returns

A string representing the bottom border.

§Example
use rich_rs::r#box::SQUARE;

let bottom = SQUARE.get_bottom(&[5, 10, 5]);
assert_eq!(bottom, "└─────┴──────────┴─────┘");
Source

pub fn top_edge(&self, width: usize) -> String

Get a string for the top edge of a simple box (single column).

This is a convenience method for backward compatibility with the original BoxChars implementation.

§Arguments
  • width - The width of the box interior.
§Returns

A string representing the top edge.

Source

pub fn bottom_edge(&self, width: usize) -> String

Get a string for the bottom edge of a simple box (single column).

This is a convenience method for backward compatibility with the original BoxChars implementation.

§Arguments
  • width - The width of the box interior.
§Returns

A string representing the bottom edge.

Trait Implementations§

Source§

impl Clone for Box

Source§

fn clone(&self) -> Box

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 Box

Source§

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

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

impl PartialEq for Box

Source§

fn eq(&self, other: &Box) -> 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.
Source§

impl Copy for Box

Source§

impl Eq for Box

Source§

impl StructuralPartialEq for Box

Auto Trait Implementations§

§

impl Freeze for Box

§

impl RefUnwindSafe for Box

§

impl Send for Box

§

impl Sync for Box

§

impl Unpin for Box

§

impl UnwindSafe for Box

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

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> 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.