Trait DialogBox

Source
pub trait DialogBox {
    type Output;

    // Required method
    fn show_with<B>(&self, backend: impl AsRef<B>) -> Result<Self::Output>
       where B: Backend + ?Sized;

    // Provided method
    fn show(&self) -> Result<Self::Output> { ... }
}
Expand description

A dialog box that can be shown using a backend.

Some dialog boxes might return data of the type Output.

Required Associated Types§

Source

type Output

The type of the data returned by the dialog box.

Required Methods§

Source

fn show_with<B>(&self, backend: impl AsRef<B>) -> Result<Self::Output>
where B: Backend + ?Sized,

Shows this dialog box using the given backend and returns the output.

Provided Methods§

Source

fn show(&self) -> Result<Self::Output>

Shows this dialog box using the default backend and returns the output.

box.show() is a shorthand for box.show_with(default_backend()).

Examples found in repository?
examples/question.rs (line 7)
6fn main() -> dialog::Result<()> {
7    let choice = dialog::Question::new("Do you want to continue?").show()?;
8    println!("The user chose: {:?}", choice);
9    Ok(())
10}
More examples
Hide additional examples
examples/message.rs (line 7)
6fn main() -> dialog::Result<()> {
7    dialog::Message::new("This is a message.").show()?;
8
9    dialog::Message::new("This is a message.")
10        .title("And this is a title:")
11        .show()
12}
examples/password.rs (line 9)
6fn main() -> dialog::Result<()> {
7    let password = dialog::Password::new("Please enter a new password")
8        .title("Password")
9        .show()?;
10    match password {
11        Some(password) => println!("Your new password is: {}", password),
12        None => println!("You do not want to have a password."),
13    };
14    Ok(())
15}
examples/input.rs (line 7)
6fn main() -> dialog::Result<()> {
7    let input1 = dialog::Input::new("Please enter something").show()?;
8    let input2 = dialog::Input::new("Please enter something")
9        .title("Input form")
10        .show()?;
11    let input3 = dialog::Input::new("Please enter something with a default")
12        .title("Input form")
13        .default("input")
14        .show()?;
15
16    println!("Input 1: {:?}", input1);
17    println!("Input 2: {:?}", input2);
18    println!("Input 3: {:?}", input3);
19    Ok(())
20}
examples/file_selection.rs (line 10)
6fn main() -> dialog::Result<()> {
7    let choice = dialog::FileSelection::new("Please select a file")
8        .title("File Chooser Example (Open)")
9        .path("/etc")
10        .show()?;
11    println!("The user chose: {:?}", choice);
12
13    let choice = dialog::FileSelection::new("Please select a file")
14        .title("File Chooser Example (Save)")
15        .mode(dialog::FileSelectionMode::Save)
16        .path("/etc")
17        .show()?;
18    println!("The user chose: {:?}", choice);
19
20    Ok(())
21}

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§