Skip to content

Commit

Permalink
Merge pull request #207 from hoodie/feature/clippy
Browse files Browse the repository at this point in the history
chore: fix beta clippy warnings
  • Loading branch information
hoodie authored Apr 4, 2024
2 parents 996953c + c0ffee4 commit 673925e
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 8 additions & 9 deletions examples/close.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/show_volume.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::image::ImageError;
use std::{fmt, num};
/// Convenient wrapper around `std::Result`.
pub type Result<T> = ::std::result::Result<T, Error>;
pub type Result<T> = std::result::Result<T, Error>;

#[cfg(target_os = "macos")]
pub use crate::macos::{ApplicationError, MacOsError, NotificationError};
Expand Down
6 changes: 3 additions & 3 deletions src/hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum Hint {
/// * <https://developer.gnome.org/notification-spec/#categories>
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),

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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()))
Expand Down
12 changes: 6 additions & 6 deletions src/notification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ 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
}

/// Set the `summary`.
///
/// 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
}

Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -430,7 +430,7 @@ impl Notification {
#[cfg(feature = "async")]
// #[cfg(test)]
pub async fn show_async_at_bus(&self, sub_bus: &str) -> Result<xdg::NotificationHandle> {
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
}

Expand All @@ -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<xdg::NotificationHandle> {
Expand Down
11 changes: 3 additions & 8 deletions src/timeout.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand All @@ -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.
Expand All @@ -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));
Expand Down
1 change: 0 additions & 1 deletion src/urgency.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::ErrorKind;
use std::convert::TryFrom;

/// Levels of Urgency.
///
Expand Down
1 change: 0 additions & 1 deletion tests/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
mod conversion {

use notify_rust::Urgency;
use std::convert::{TryFrom, TryInto};

#[test]
fn urgency_from_int() {
Expand Down

0 comments on commit 673925e

Please sign in to comment.