Ui

Struct Ui 

Source
pub struct Ui<W: Write> {
    pub(crate) out: BufWriter<W>,
    pub(crate) err: Box<dyn Write>,
    pub(crate) color_enabled: bool,
    pub(crate) default_yes: bool,
    pub(crate) spinner_style: Arc<ProgressStyle>,
    pub(crate) progress_style: Arc<ProgressStyle>,
}
Expand description

Terminal-backed presentation state used by CLI command handlers.

Fields§

§out: BufWriter<W>§err: Box<dyn Write>§color_enabled: bool§default_yes: bool§spinner_style: Arc<ProgressStyle>§progress_style: Arc<ProgressStyle>

Implementations§

Source§

impl<W: Write> Ui<W>

Source

pub fn page_title(&mut self, title: &str)

Source

pub fn confirm(&mut self, message: &str, default: bool) -> Result<bool>

Source

pub fn prompt_text( &mut self, message: &str, default: Option<&str>, ) -> Result<String>

Source

pub fn prompt_number(&mut self, message: &str, max: usize) -> Result<usize>

Source

pub fn select_index(&mut self, message: &str, items: &[String]) -> Result<usize>

Source§

impl<W: Write> Ui<W>

Source

pub fn write_line(&mut self, message: impl Display)

Source

pub fn info(&mut self, message: impl Display)

Source

pub fn notice(&mut self, message: impl Display)

notice is reserved for neutral status messages; may gain distinct formatting in future (e.g. dimmed). Prefer info for general output.

Source

pub fn warn(&mut self, message: impl AsRef<str>)

Source

pub fn error(&mut self, message: impl AsRef<str>)

Source

pub fn success(&mut self, message: impl AsRef<str>)

Source§

impl<W: Write> Ui<W>

Source

pub fn progress_bar(&self) -> ProgressHandle

Source

pub fn start_spinner(&self, message: impl Into<String>) -> SpinnerGuard

Source

pub fn spinner<T, F: FnOnce() -> T>( &self, message: impl Into<String>, f: F, ) -> T

Source§

impl<W: Write> Ui<W>

Source

fn render_table(&mut self, table: Table)

Source

pub fn display_packages(&mut self, packages: &[InstalledPackage])

Source

pub fn display_catalog_packages(&mut self, packages: &[CatalogPackage])

Source

pub fn display_key_values(&mut self, rows: &[(String, String)])

Source

fn build_table(&self, headers: impl IntoIterator<Item = Cell>) -> Table

Source

fn render_section_label(&mut self, label: &str)

Source§

impl Ui<Stdout>

Source

pub fn new(settings: UiSettings) -> Self

Create a UI that writes to stdout and stderr.

Source§

impl<W: Write> Ui<W>

Source

pub fn with_writer(writer: W, settings: UiSettings) -> Self

Create a UI with an explicit writer, which is primarily useful in tests.

Trait Implementations§

Source§

impl Default for Ui<Stdout>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<W> Freeze for Ui<W>
where W: Freeze,

§

impl<W> !RefUnwindSafe for Ui<W>

§

impl<W> !Send for Ui<W>

§

impl<W> !Sync for Ui<W>

§

impl<W> Unpin for Ui<W>
where W: Unpin,

§

impl<W> !UnwindSafe for Ui<W>

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more