Skip to content

Commit

Permalink
fix: re-exported types from mac-notification-sys
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodie committed Mar 25, 2022
1 parent 0761413 commit 80daef6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Cargo.lock
.directory
*.rustfmt
*.rsx
main-doc
10 changes: 6 additions & 4 deletions examples/mac_app_id.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#[cfg(target_os = "macos")]
fn main() -> Result<(), String> {
use notify_rust::{
get_bundle_identifier_or_default, set_application, Notification,
};
use notify_rust::{error::MacOsError, get_bundle_identifier_or_default, set_application, Notification};

let safari_id = get_bundle_identifier_or_default("Safari");
set_application(&safari_id).map_err(|f| format!("{}", f))?;

set_application(&safari_id).map_err(|f| format!("{}", f))?;
match set_application(&safari_id) {
Ok(_) => {}
Err(MacOsError::Application(error)) => println!("{}", error),
Err(MacOsError::Notification(error)) => println!("{}", error),
}

Notification::new()
.summary("Safari Crashed")
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use std::{fmt, num};
/// Convenient wrapper around `std::Result`.
pub type Result<T> = ::std::result::Result<T, Error>;

#[cfg(target_os = "macos")]
pub use crate::macos::{ApplicationError, MacOsError, NotificationError};

/// The Error type.
#[derive(Debug)]
pub struct Error {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ mod notification;
pub(crate) mod urgency;

#[cfg(target_os = "macos")] pub use mac_notification_sys::{get_bundle_identifier_or_default, set_application};
#[cfg(target_os = "macos")] pub use macos::*;
#[cfg(target_os = "macos")] pub use macos::NotificationHandle;

#[cfg(all(any(feature = "dbus", feature = "zbus"), unix, not(target_os = "macos")))]
pub use crate::xdg::{
Expand Down
5 changes: 4 additions & 1 deletion src/macos.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
pub use crate::{error::*, notification::Notification};
use crate::{error::*, notification::Notification};

pub use mac_notification_sys::error::{Error as MacOsError, NotificationError,ApplicationError};


use std::ops::{Deref, DerefMut};

Expand Down

0 comments on commit 80daef6

Please sign in to comment.