Skip to content

Commit

Permalink
docs: add doc test for Timeout::from_str
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Dec 11, 2022
1 parent b87b859 commit 208d55d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 9 additions & 0 deletions src/timeout.rs
@@ -1,6 +1,15 @@
use std::{num::ParseIntError, str::FromStr};

/// Describes the timeout of a notification
///
/// # `FromStr`
/// You can also parse a `Timeout` from a `&str`.
/// ```
/// # use notify_rust::Timeout;
/// assert_eq!("default".parse(), Ok(Timeout::Default));
/// assert_eq!("never".parse(), Ok(Timeout::Never));
/// assert_eq!("42".parse(), Ok(Timeout::Milliseconds(42)));
/// ```
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum Timeout {
/// Expires according to server default.
Expand Down
8 changes: 4 additions & 4 deletions src/xdg/mod.rs
Expand Up @@ -302,23 +302,23 @@ pub(crate) fn show_notification(notification: &Notification) -> Result<Notificat
}
}

/// Get the currently dsed [`DbusStack`]
/// Get the currently used [`DbusStack`]
///
/// (zbus only)
#[cfg(all(feature = "zbus", not(feature = "dbus")))]
pub fn dbus_stack() -> Option<DbusStack> {
Some(DbusStack::Zbus)
}

/// Get the currently dsed [`DbusStack`]
/// Get the currently used [`DbusStack`]
///
/// (dbus-rs only)
#[cfg(all(feature = "dbus", not(feature = "zbus")))]
pub fn dbus_stack() -> Option<DbusStack> {
Some(DbusStack::Dbus)
}

/// Get the currently dsed [`DbusStack`]
/// Get the currently used [`DbusStack`]
///
/// both dbus-rs and zbus, switch via `$ZBUS_NOTIFICATION`
#[cfg(all(feature = "dbus", feature = "zbus"))]
Expand All @@ -330,7 +330,7 @@ pub fn dbus_stack() -> Option<DbusStack> {
})
}

/// Get the currently dsed [`DbusStack`]
/// Get the currently used [`DbusStack`]
///
/// neither zbus nor dbus-rs are configured
#[cfg(all(not(feature = "dbus"), not(feature = "zbus")))]
Expand Down

0 comments on commit 208d55d

Please sign in to comment.