diff --git a/Cargo.toml b/Cargo.toml index f6df4f18c..ac7088dda 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ description = "Show desktop notifications (linux, bsd, mac). Pure Rust dbus clie repository = "https://github.com/hoodie/notify-rust" documentation = "https://docs.rs/notify-rust/" edition = "2021" -rust-version = "1.59.0" +rust-version = "1.63.0" license = "MIT/Apache-2.0" keywords = ["desktop", "notification", "notify", "linux", "macos"] readme = "README.md" diff --git a/examples/close.rs b/examples/close.rs index ea1957c48..3f00d16f5 100644 --- a/examples/close.rs +++ b/examples/close.rs @@ -1,20 +1,19 @@ -use notify_rust::*; - #[cfg(any(target_os = "windows", target_os = "macos"))] fn main() { println!("this is a xdg only feature") } -fn wait_for_keypress(msg: &str) { - println!("{}", msg); - std::io::stdin().read_line(&mut String::new()).unwrap(); -} - #[cfg(all(unix, not(target_os = "macos")))] fn main() { - let handle: notify_rust::NotificationHandle = Notification::new() + use notify_rust::*; + fn wait_for_keypress(msg: &str) { + println!("{}", msg); + std::io::stdin().read_line(&mut String::new()).unwrap(); + } + + let handle: NotificationHandle = Notification::new() .summary("oh no") - .hint(notify_rust::Hint::Transient(true)) + .hint(Hint::Transient(true)) .body("I'll be here till you close me!") .hint(Hint::Resident(true)) // does not work on kde .timeout(Timeout::Never) // works on kde and gnome diff --git a/examples/show_volume.rs b/examples/show_volume.rs index a2cc4d465..b7be1526f 100644 --- a/examples/show_volume.rs +++ b/examples/show_volume.rs @@ -17,7 +17,7 @@ enum Volume { fn show_volume(percent: Volume) { let icon = match percent { Volume::Muted => "notification-audio-volume-muted", - Volume::Percent(x) if x == 0 => "notification-audio-volume-off", + Volume::Percent(0) => "notification-audio-volume-off", Volume::Percent(x) if x < 33 => "notification-audio-volume-low", Volume::Percent(x) if x < 67 => "notification-audio-volume-medium", _ => "notification-audio-volume-high", diff --git a/src/error.rs b/src/error.rs index cf8f0448d..9cd3483e3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -4,7 +4,7 @@ use crate::image::ImageError; use std::{fmt, num}; /// Convenient wrapper around `std::Result`. -pub type Result = ::std::result::Result; +pub type Result = std::result::Result; #[cfg(target_os = "macos")] pub use crate::macos::{ApplicationError, MacOsError, NotificationError}; diff --git a/src/hints.rs b/src/hints.rs index 6a0c9b84f..29ebd3365 100644 --- a/src/hints.rs +++ b/src/hints.rs @@ -48,7 +48,7 @@ pub enum Hint { /// * Category(String), - /// Name of the DesktopEntry representing the calling application. In case of "firefox.desktop" + /// Name of the `DesktopEntry` representing the calling application. In case of "firefox.desktop" /// use "firefox". May be used to retrieve the correct icon. DesktopEntry(String), @@ -91,7 +91,7 @@ pub enum Hint { /// A custom numerical (integer) hint CustomInt(String, i32), - /// Only used by this NotificationServer implementation + /// Only used by this `NotificationServer` implementation Invalid // TODO find a better solution to this } @@ -154,7 +154,7 @@ fn test_hints_to_map() { // custom value should only be there once if the names are identical - let n1 = crate::Notification::new() + let n1 = Notification::new() .hint(Hint::Custom("foo".into(), "bar1".into())) .hint(Hint::Custom("foo".into(), "bar2".into())) .hint(Hint::Custom("f00".into(), "bar3".into())) diff --git a/src/notification.rs b/src/notification.rs index 20bb2e110..6bf148d49 100644 --- a/src/notification.rs +++ b/src/notification.rs @@ -127,7 +127,7 @@ impl Notification { /// # Platform Support /// Please note that this method has no effect on macOS. Here you can only set the application via [`set_application()`](fn.set_application.html) pub fn appname(&mut self, appname: &str) -> &mut Notification { - self.appname = appname.to_owned(); + appname.clone_into(&mut self.appname); self } @@ -135,7 +135,7 @@ impl Notification { /// /// Often acts as title of the notification. For more elaborate content use the `body` field. pub fn summary(&mut self, summary: &str) -> &mut Notification { - self.summary = summary.to_owned(); + summary.clone_into(&mut self.summary); self } @@ -206,7 +206,7 @@ impl Notification { /// Each line should be treated as a paragraph. /// Simple html markup should be supported, depending on the server implementation. pub fn body(&mut self, body: &str) -> &mut Notification { - self.body = body.to_owned(); + body.clone_into(&mut self.body); self } @@ -219,7 +219,7 @@ impl Notification { /// # Platform support /// macOS does not have support manually setting the icon. However you can pretend to be another app using [`set_application()`](fn.set_application.html) pub fn icon(&mut self, icon: &str) -> &mut Notification { - self.icon = icon.to_owned(); + icon.clone_into(&mut self.icon); self } @@ -430,7 +430,7 @@ impl Notification { #[cfg(feature = "async")] // #[cfg(test)] pub async fn show_async_at_bus(&self, sub_bus: &str) -> Result { - let bus = crate::xdg::NotificationBus::custom(sub_bus).ok_or("invalid subpath")?; + let bus = xdg::NotificationBus::custom(sub_bus).ok_or("invalid subpath")?; xdg::show_notification_async_at_bus(self, bus).await } @@ -452,7 +452,7 @@ impl Notification { windows::show_notification(self) } - /// Wraps show() but prints notification to stdout. + /// Wraps `show()` but prints notification to stdout. #[cfg(all(unix, not(target_os = "macos")))] #[deprecated = "this was never meant to be public API"] pub fn show_debug(&mut self) -> Result { diff --git a/src/timeout.rs b/src/timeout.rs index 295c97eed..a68abe324 100644 --- a/src/timeout.rs +++ b/src/timeout.rs @@ -1,4 +1,4 @@ -use std::{convert::TryInto, num::ParseIntError, str::FromStr, time::Duration}; +use std::{num::ParseIntError, str::FromStr, time::Duration}; /// Describes the timeout of a notification /// @@ -10,11 +10,12 @@ use std::{convert::TryInto, num::ParseIntError, str::FromStr, time::Duration}; /// assert_eq!("never".parse(), Ok(Timeout::Never)); /// assert_eq!("42".parse(), Ok(Timeout::Milliseconds(42))); /// ``` -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Default, Copy, Clone, PartialEq, Eq)] pub enum Timeout { /// Expires according to server default. /// /// Whatever that might be... + #[default] Default, /// Do not expire, user will have to close this manually. @@ -24,12 +25,6 @@ pub enum Timeout { Milliseconds(u32), } -impl Default for Timeout { - fn default() -> Self { - Timeout::Default - } -} - #[test] fn timeout_from_i32() { assert_eq!(Timeout::from(234), Timeout::Milliseconds(234)); diff --git a/src/urgency.rs b/src/urgency.rs index 18414664c..25cdabb2d 100644 --- a/src/urgency.rs +++ b/src/urgency.rs @@ -1,5 +1,4 @@ use crate::error::ErrorKind; -use std::convert::TryFrom; /// Levels of Urgency. /// diff --git a/tests/conversion.rs b/tests/conversion.rs index 8301e4d7b..fc3ba6f6b 100644 --- a/tests/conversion.rs +++ b/tests/conversion.rs @@ -2,7 +2,6 @@ mod conversion { use notify_rust::Urgency; - use std::convert::{TryFrom, TryInto}; #[test] fn urgency_from_int() {