Skip to main content

UserInterface

Trait UserInterface 

Source
pub trait UserInterface: Send + Sync {
    // Required methods
    fn has_ui(&self) -> bool;
    fn notify<'life0, 'life1, 'async_trait>(
        &'life0 self,
        message: &'life1 str,
        level: NotifyLevel,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn confirm<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        title: &'life1 str,
        message: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn select_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        title: &'life1 str,
        context: &'life2 str,
        options: &'life3 [SelectOption],
    ) -> Pin<Box<dyn Future<Output = Option<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn input_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        title: &'life1 str,
        context: &'life2 str,
        placeholder: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn set_status<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        text: Option<&'life2 str>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn set_widget<'life0, 'life1, 'async_trait>(
        &'life0 self,
        key: &'life1 str,
        content: Option<WidgetContent>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn custom<'life0, 'async_trait>(
        &'life0 self,
        component: ComponentSpec,
    ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn select<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        title: &'life1 str,
        options: &'life2 [SelectOption],
    ) -> Pin<Box<dyn Future<Output = Option<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn input<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        title: &'life1 str,
        placeholder: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Abstraction over user interaction. Tools and extensions use this without knowing whether they’re in a TUI, headless, or print mode.

Required Methods§

Source

fn has_ui(&self) -> bool

Whether this interface can show interactive UI.

Source

fn notify<'life0, 'life1, 'async_trait>( &'life0 self, message: &'life1 str, level: NotifyLevel, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Non-blocking notification.

Source

fn confirm<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, title: &'life1 str, message: &'life2 str, ) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Yes/no confirmation. Returns None if no UI or cancelled.

Source

fn select_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, title: &'life1 str, context: &'life2 str, options: &'life3 [SelectOption], ) -> Pin<Box<dyn Future<Output = Option<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Select from options with context. Returns None if no UI or cancelled.

Source

fn input_with_context<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, title: &'life1 str, context: &'life2 str, placeholder: &'life3 str, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Text input with context. Returns None if no UI or cancelled.

Source

fn set_status<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, key: &'life1 str, text: Option<&'life2 str>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Persistent status in footer.

Source

fn set_widget<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, content: Option<WidgetContent>, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Widget above/below editor.

Source

fn custom<'life0, 'async_trait>( &'life0 self, component: ComponentSpec, ) -> Pin<Box<dyn Future<Output = Option<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Full declarative custom component. Returns the serialized result.

Provided Methods§

Source

fn select<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, title: &'life1 str, options: &'life2 [SelectOption], ) -> Pin<Box<dyn Future<Output = Option<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Select from options. Returns None if no UI or cancelled.

Source

fn input<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, title: &'life1 str, placeholder: &'life2 str, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Text input. Returns None if no UI or cancelled.

Implementors§