Skip to main content

Graphics

Struct Graphics 

Source
#[non_exhaustive]
pub struct Graphics { pub horizontal: char, pub vertical: char, pub junction: char, pub tip: char, pub end: char, }
Expand description

Character set used for drawing tree graphics in the terminal.

Each tree display uses a set of five characters to render the hierarchical structure. Different styles are available for ASCII-only terminals, Unicode-capable terminals, and various aesthetic preferences.

§Example

use tree_display::Graphics;

// Use ASCII characters for maximum compatibility
let ascii = Graphics::ASCII;

// Use modern Unicode box-drawing characters
let light = Graphics::LIGHT;

// Customize individual characters
let custom = Graphics::new()
  .vertical('│')
  .horizontal('─')
  .tip('└');

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§horizontal: char

Character for horizontal lines connecting to labels

§vertical: char

Character for vertical lines connecting tree levels

§junction: char

Character for branch junctions (middle child)

§tip: char

Character for the tip/end of a branch (last child)

§end: char

Character for the end of the tree (root connector)

Implementations§

Source§

impl Graphics

Source

pub const BLANK: Self

Minimal graphics with no visible characters (spaces only).

Uses for all characters, effectively disabling tree lines.

Source

pub const ASCII: Self

Pure ASCII characters (compatible with all terminals).

Uses -, |, +, -, and ` for tree drawing.

Source

pub const LIGHT: Self

Light-weight Unicode box-drawing characters.

Uses ─, │, ├, ─, and └ for tree drawing.

Source

pub const LIGHT_DOTTED: Self

Light-weight Unicode box-drawing characters with dotted lines.

Uses ╌, │, ├, ─, and └ for tree drawing.

Source

pub const LIGHT_ROUNDED: Self

Light-weight Unicode box-drawing characters with rounded corners.

Uses ─, │, ├, ─, and ╰ for tree drawing.

Source

pub const LIGHT_DOTTED_ROUNDED: Self

Light-weight Unicode box-drawing characters with dotted lines and rounded corners.

Uses ╌, │, ├, ─, and ╰ for tree drawing.

Source

pub const DOUBLE: Self

Double-line Unicode box-drawing characters.

Uses ═, ║, ╠, ━, and ╚ for tree drawing.

Source

pub const HEAVY: Self

Heavy-weight Unicode box-drawing characters.

Uses ━, ┃, ┣, ━, and ┗ for tree drawing.

Source

pub const HEAVY_DOTTED: Self

Heavy-weight Unicode box-drawing characters with dotted lines.

Uses ╍, ╏, ┣, ━, and ┗ for tree drawing.

Source§

impl Graphics

Source

pub const fn new() -> Self

Creates a new Graphics instance with LIGHT characters.

Source

pub const fn horizontal(self, c: char) -> Self

Sets the horizontal line character.

This character is used for horizontal connections extending from vertical lines to labels.

Source

pub const fn vertical(self, c: char) -> Self

Sets the vertical line character.

This character is used for vertical lines that connect tree levels.

Source

pub const fn junction(self, c: char) -> Self

Sets the junction character.

This character is used at branch junctions where horizontal and vertical lines meet. It represents the “T-junction” where a branch splits.

Source

pub const fn tip(self, c: char) -> Self

Sets the tip character.

This character is used for the tip/end of a branch (the last child).

Source

pub const fn end(self, c: char) -> Self

Sets the end character.

This character is used at the root of the tree or as the final connector in the hierarchy. In some styles, it may be the same as the tip character.

Source

pub const fn all(self, c: char) -> Self

Sets all graphics characters to the same value.

This is a convenience method for quickly creating a uniform style where all characters are identical.

Trait Implementations§

Source§

impl Clone for Graphics

Source§

fn clone(&self) -> Graphics

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 Copy for Graphics

Source§

impl Debug for Graphics

Source§

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

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

impl Default for Graphics

Source§

fn default() -> Self

Creates a new Graphics instance with LIGHT characters.

Source§

impl Eq for Graphics

Source§

impl Ord for Graphics

Source§

fn cmp(&self, other: &Graphics) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Graphics

Source§

fn eq(&self, other: &Graphics) -> 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 PartialOrd for Graphics

Source§

fn partial_cmp(&self, other: &Graphics) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Graphics

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

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> Content for T
where T: Debug + Any,

Source§

fn to_string(&self, theme: &Theme) -> String

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<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,

Source§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

Source§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
Source§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
Source§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
Source§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
Source§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a MaybeRef.
Source§

impl<T, S> SpanWrap<S> for T
where S: WrappingSpan<T>,

Source§

fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned

Invokes WrappingSpan::make_wrapped to wrap an AST node in a span.
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.