scarb_ui/widget.rs
1use indicatif::WeakProgressBar;
2
3/// A persistent message that is only usable for humans, for example a spinner.
4pub trait Widget {
5 /// Allows for live interaction with the widget, and its drop is called when the widget should
6 /// be cleared.
7 type Handle: WidgetHandle;
8
9 /// Display the widget on the standard output, and return a handle for further interaction.
10 fn text(self) -> Self::Handle;
11}
12
13/// A handle to a widget that allows for further interaction.
14pub trait WidgetHandle {
15 #[doc(hidden)]
16 fn weak_progress_bar(&self) -> Option<WeakProgressBar>;
17}