[][src]Struct boxx::Boxx

pub struct Boxx {
    pub config: Config,
}

Boxx is a customizable data structure that will pretty print content separated by newlines (\n).

Fields

config: Config

Display configuration of the Boxx. This field dictates how a Boxx will be displayed in the terminal.

Methods

impl Boxx[src]

pub fn default() -> Boxx[src]

Create a Boxx with deafult configuration.

Example

use boxx::Boxx;

let boxx = Boxx::default();

pub fn new(config: Config) -> Boxx[src]

Creates a new Boxx from a pre-made Config.

Example

use boxx::{Boxx, Config};

let config = Config::default();
let boxx = Boxx::new(config);

pub fn builder() -> Config[src]

Get a configuration builder to customize the appearance of a Boxx.

Example

use boxx::Boxx;

let boxx = Boxx::builder().padding(3).margin(1).build();

pub fn display(&self, content: &str)[src]

Prints your Boxxed content to stdout If your content is long, separate it with line breaks (\n).

If the user's terminal is too small, or something goes wrong with displaying your content in a box, this function will print the content passed to it with no modifications.

If you would like to handle specific error cases, it is recommended to use .as_str() directly.

Example

use boxx::Boxx;

Boxx::default().display("Hello, World!\nNew lines can be created with the newline separator :).");

pub fn as_str(&self, content: &str) -> Result<String, VisualWidthError>[src]

Get your content in a Boxx as a String.

Example

use boxx::Boxx;

let result = Boxx::default().as_str("Hello, World!")?;
println!("{}", result);

Trait Implementations

impl Clone for Boxx[src]

impl Debug for Boxx[src]

impl PartialEq<Boxx> for Boxx[src]

impl StructuralPartialEq for Boxx[src]

Auto Trait Implementations

impl RefUnwindSafe for Boxx

impl Send for Boxx

impl Sync for Boxx

impl Unpin for Boxx

impl UnwindSafe for Boxx

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.