Struct Message

Source
pub struct Message { /* private fields */ }
Expand description

A message box.

This dialog box displays a text and an optional title and has a single OK button. It does not produce any output.

§Example

use dialog::DialogBox;

dialog::Message::new("The operation was successful.")
    .title("Success")
    .show()
    .expect("Could not display dialog box");

Implementations§

Source§

impl Message

Source

pub fn new(text: impl Into<String>) -> Message

Creates a new message box with the given text.

Examples found in repository?
examples/backend-stdio.rs (line 10)
7fn main() -> dialog::Result<()> {
8    let backend = backends::Stdio::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)
13}
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/backend-kdialog.rs (line 10)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::KDialog::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_icon("error");
15    dialog::Message::new("This is an error message.")
16        .title("Error")
17        .show_with(&backend)
18}
examples/backend-dialog.rs (line 10)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::Dialog::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_backtitle("Backtitle");
15    dialog::Message::new("This is a message.")
16        .title("And this is a title:")
17        .show_with(&backend)?;
18
19    backend.set_width(100);
20    backend.set_height(10);
21    dialog::Message::new("This is a message with a fixed size.")
22        .title("And this is a title:")
23        .show_with(&backend)
24}
examples/backend-zenity.rs (line 10)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::Zenity::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_width(500);
15    backend.set_height(200);
16    dialog::Message::new("This is a message with a fixed size.")
17        .title("And this is a title:")
18        .show_with(&backend)?;
19
20    let mut backend = backends::Zenity::new();
21    backend.set_timeout(5);
22    dialog::Message::new("This box should disappear after five seconds.")
23        .title("And this is a title:")
24        .show_with(&backend)
25}
Source

pub fn title(&mut self, title: impl Into<String>) -> &mut Message

Sets the title of this message box.

This method returns a reference to self to enable chaining.

Examples found in repository?
examples/backend-stdio.rs (line 11)
7fn main() -> dialog::Result<()> {
8    let backend = backends::Stdio::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)
13}
More examples
Hide additional examples
examples/message.rs (line 10)
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/backend-kdialog.rs (line 11)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::KDialog::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_icon("error");
15    dialog::Message::new("This is an error message.")
16        .title("Error")
17        .show_with(&backend)
18}
examples/backend-dialog.rs (line 11)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::Dialog::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_backtitle("Backtitle");
15    dialog::Message::new("This is a message.")
16        .title("And this is a title:")
17        .show_with(&backend)?;
18
19    backend.set_width(100);
20    backend.set_height(10);
21    dialog::Message::new("This is a message with a fixed size.")
22        .title("And this is a title:")
23        .show_with(&backend)
24}
examples/backend-zenity.rs (line 11)
7fn main() -> dialog::Result<()> {
8    let mut backend = backends::Zenity::new();
9
10    dialog::Message::new("This is a message.")
11        .title("And this is a title:")
12        .show_with(&backend)?;
13
14    backend.set_width(500);
15    backend.set_height(200);
16    dialog::Message::new("This is a message with a fixed size.")
17        .title("And this is a title:")
18        .show_with(&backend)?;
19
20    let mut backend = backends::Zenity::new();
21    backend.set_timeout(5);
22    dialog::Message::new("This box should disappear after five seconds.")
23        .title("And this is a title:")
24        .show_with(&backend)
25}

Trait Implementations§

Source§

impl DialogBox for Message

Source§

type Output = ()

The type of the data returned by the dialog box.
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.
Source§

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

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

Auto Trait Implementations§

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.

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, 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.