Dialog

Trait Dialog 

Source
pub trait Dialog: Sized {
    type Update;
    type Output;

    // Required methods
    fn update_for_event(event: Event) -> Option<Self::Update>;
    fn perform_update(&mut self, update: Self::Update) -> Result<()>;
    fn state(&self) -> DialogState;
    fn output(self) -> Self::Output;
    fn viewport(&self) -> Viewport;
    fn draw(&mut self, frame: &mut Frame<'_>);

    // Provided methods
    fn run(self) -> Result<Self::Output> { ... }
    fn tick(&mut self) -> bool { ... }
    fn tick_rate(&self) -> Duration { ... }
    fn timeout(&self) -> Option<Duration> { ... }
}

Required Associated Types§

Required Methods§

Source

fn update_for_event(event: Event) -> Option<Self::Update>

Source

fn perform_update(&mut self, update: Self::Update) -> Result<()>

Source

fn state(&self) -> DialogState

Source

fn output(self) -> Self::Output

Source

fn viewport(&self) -> Viewport

Source

fn draw(&mut self, frame: &mut Frame<'_>)

Provided Methods§

Source

fn run(self) -> Result<Self::Output>

Examples found in repository?
examples/input.rs (line 8)
5fn main() -> anyhow::Result<()> {
6    InputDialog::default()
7        .with_prompt(Prompt::inline("Enter some text :) "))
8        .run()?;
9    Ok(())
10}
More examples
Hide additional examples
examples/select.rs (line 5)
4fn main() -> anyhow::Result<()> {
5    let result = SelectDialog::new(vec!["one".into(), "two".into(), "three".into()]).run()?;
6    println!("{}", result.unwrap_or("<none>".into()));
7    Ok(())
8}
examples/yes_no.rs (line 5)
4fn main() -> anyhow::Result<()> {
5    let result = YesNoDialog::default().with_message("Yes or no?").run()?;
6    let display = if result { "yes" } else { "no" };
7    println!("You chose: {display}");
8    Ok(())
9}
Source

fn tick(&mut self) -> bool

Source

fn tick_rate(&self) -> Duration

Source

fn timeout(&self) -> Option<Duration>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§