Skip to main content

ConsoleBuilder

Struct ConsoleBuilder 

Source
pub struct ConsoleBuilder { /* private fields */ }
Expand description

Builder for Console, allowing detection to be overridden.

Implementations§

Source§

impl ConsoleBuilder

Source

pub fn log_time(self, value: bool) -> Self

Show the time column in Console::log (default on). Port of Console(log_time=…).

Source

pub fn log_path(self, value: bool) -> Self

Show the caller’s file and line in Console::log (default on). Port of Console(log_path=…).

Source

pub fn log_time_format(self, format: impl Into<String>) -> Self

The strftime format of the time column in Console::log (default "[%X]"). Port of Console(log_time_format="…"); the time is formatted in UTC (see get_datetime).

Source

pub fn log_time_formatter( self, format: impl Fn(SystemTime) -> Text + Send + Sync + 'static, ) -> Self

Format the time column of Console::log with format. Port of Console(log_time_format=callable).

Source

pub fn get_datetime( self, clock: impl Fn() -> SystemTime + Send + Sync + 'static, ) -> Self

Read the time Console::log shows from clock (default SystemTime::now). Port of Console(get_datetime=…). Upstream’s datetime.now() is local time; core has no time zone data, so its strftime formats the UTC wall-clock time, and a clock that wants local time adds the offset.

Source

pub fn record(self, value: bool) -> Self

Record what is written (default off), for Console::export_text_recorded, Console::export_html_recorded and Console::export_svg_recorded. Port of Console(record=…).

Source

pub fn environ(self, environ: Environ) -> Self

Detect the terminal from environ instead of the process environment: NO_COLOR, COLUMNS, LINES, TERM, COLORTERM, TTY_COMPATIBLE and FORCE_COLOR. Port of Console(_environ=…), which upstream provides for tests.

Source

pub fn quiet(self, value: bool) -> Self

Suppress all output (default off). Port of Console(quiet=…).

Source

pub fn soft_wrap(self, value: bool) -> Self

The default of print(soft_wrap=…) (default off): no wrapping and no cropping. Port of Console(soft_wrap=…).

Source

pub fn style(self, style: impl Into<StyleType>) -> Self

A style applied to all output (default none). Port of Console(style=…).

Source

pub fn on_broken_pipe( self, handler: impl Fn(&Console) + Send + Sync + 'static, ) -> Self

Call handler in place of Console::on_broken_pipe’s default (quiet, then exit with status 1) when a write finds the pipe closed. Upstream overrides Console.on_broken_pipe in a subclass.

Source

pub fn markup(self, value: bool) -> Self

Enable/disable console markup in printed strings (default enabled). Port of Console(markup=…).

Source

pub fn emoji_variant(self, variant: Option<EmojiVariant>) -> Self

The emoji variant appended to codes that name none (default none). Port of Console(emoji_variant=…).

Source

pub fn tab_size(self, tab_size: usize) -> Self

The tab stop width Text expands tabs to (default 8). Port of Console(tab_size=…).

Source

pub fn force_terminal(self, value: bool) -> Self

Source

pub fn legacy_windows(self, value: bool) -> Self

Force legacy-Windows-console behavior (box substitution). Default off.

Source

pub fn safe_box(self, value: bool) -> Self

Enable/disable terminal-safe box substitution (default on).

Source

pub fn ascii_only(self, value: bool) -> Self

Force ASCII-only box rendering (default off). Set for non-UTF-8 terminals.

Source

pub fn color_system(self, system: Option<ColorSystem>) -> Self

Force a specific color system (use for reproducible output/tests).

Source

pub fn width(self, width: usize) -> Self

Source

pub fn height(self, height: usize) -> Self

Set the console height in rows (used by Layout).

Source

pub fn no_color(self, value: bool) -> Self

Enable no-colour mode: colours are stripped from output while other attributes (bold, underline, …) still render. Unset, a non-empty NO_COLOR environment variable enables it. Port of no_color=.

Source

pub fn get_time(self, clock: impl Fn() -> f64 + Send + Sync + 'static) -> Self

Read the current time (seconds) from clock instead of the monotonic clock. Port of Console(get_time=…); animations such as Spinner render the frame for this time.

Source

pub fn emoji(self, value: bool) -> Self

Enable/disable :emoji: shortcode replacement (default enabled).

Source

pub fn highlight(self, value: bool) -> Self

Enable/disable automatic repr highlighting. Defaults to on, matching upstream Console(highlight=True).

Source

pub fn theme(self, theme: Theme) -> Self

Source

pub fn build(self) -> Console

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.