Skip to main content

View

Struct View 

Source
pub struct View {
    pub format: OutputFormat,
    pub color: ColorMode,
    pub quiet: bool,
    /* private fields */
}
Available on crate feature view only.
Expand description

How to present a model. JSON never contains ANSI.

Fields§

§format: OutputFormat

Pretty or JSON.

§color: ColorMode

ANSI policy for pretty output.

§quiet: bool

Suppress successful pretty output.

Implementations§

Source§

impl View

Source

pub const fn new(format: OutputFormat, color: ColorMode) -> Self

Build a view that prints successes.

Source

pub const fn json_layout(self, layout: JsonLayout) -> Self

Lay out JSON output as layout. This beats the environment.

Source

pub const fn json_layout_envs(self, names: &'static [&'static str]) -> Self

Replace the ordered environment names read for the JSON layout. An empty slice disables lookup.

Source

pub fn layout(self) -> JsonLayout

JSON layout: the owner’s choice, then the environment, then the default.

Source

pub const fn styles(self, styles: RenderOptions) -> Self

Take record style, list style, and row separation from styles. Its color and width settings are ignored; the view owns those.

Source

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

Suppress successful pretty output when quiet is set.

Source

pub const fn width(self, width: u16) -> Self

Force an explicit presentation width.

Source

pub const fn automatic_width_buffer(self, columns: u16) -> Self

Override the buffer subtracted from automatically detected widths. Zero disables buffering. Explicit Self::width remains exact.

Source

pub const fn automatic_width_buffer_envs( self, names: &'static [&'static str], ) -> Self

Replace the ordered environment names used for the automatic buffer.

Source

pub const fn minimum_automatic_width(self, columns: u16) -> Self

Set the floor for automatically detected effective widths.

Source

pub const fn fallback_width(self, width: Option<u16>) -> Self

Lay out to width when no width is detected; None disables it.

Source

pub const fn explicit_automatic_width_buffer(self) -> Option<u16>

Explicit automatic-width buffer, when set.

Source

pub const fn automatic_width_buffer_env_names(self) -> &'static [&'static str]

Ordered environment names used for the automatic-width buffer.

Source

pub const fn automatic_width_minimum(self) -> u16

Floor applied only to automatically detected widths.

Source

pub fn capture(self, value: &impl Present) -> Result<Captured>

Render without writing. Tests and alternate transports use this path.

§Errors

Returns an error when value does not serialize to JSON.

Source

pub fn show(self, value: &impl Present) -> Result<ExitCode>

Render and write one typed model. Returns its process exit semantics.

§Errors

Returns an error when value does not serialize to JSON, or when writing to stdout or stderr fails.

Source

pub fn emit_err(self, bin: &str, message: &str) -> Result<ExitCode>

Emit {bin}: {message} or a JSON error envelope.

§Errors

Returns an error when writing to stdout or stderr fails.

Trait Implementations§

Source§

impl Clone for View

Source§

fn clone(&self) -> Self

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 View

Source§

impl Debug for View

Source§

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

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

impl Eq for View

Source§

impl PartialEq for View

Source§

fn eq(&self, other: &Self) -> 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 View

Auto Trait Implementations§

§

impl Freeze for View

§

impl RefUnwindSafe for View

§

impl Send for View

§

impl Sync for View

§

impl Unpin for View

§

impl UnsafeUnpin for View

§

impl UnwindSafe for View

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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, O> Matches<O> for T
where T: PartialEq<O>,

Source§

fn validate_matches(&self, other: &O) -> bool

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 = !

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.