| 1 | #![allow(missing_docs)] |
| 2 | |
| 3 | #[cfg(all(feature = "images_no_default_features", unix, not(target_os = "macos")))] |
| 4 | use craterust-analyzer cargo notify-rust 4.18.0 crate/::imagerust-analyzer cargo notify-rust 4.18.0 image/::ImageErrorrust-analyzer cargo notify-rust 4.18.0 image/ImageError#; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/}; |
| 6 | /// Convenient wrapper around `std::Result`. |
| 7 | pub type Resultrust-analyzer cargo notify-rust 4.18.0 error/Result#<T> = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, Errorrust-analyzer cargo notify-rust 4.18.0 error/Error#>; |
| 8 | |
| 9 | #[cfg(all(target_os = "macos", not(feature = "preview-macos-un")))] |
| 10 | pub use craterust-analyzer cargo notify-rust 4.18.0 crate/::macos::{ApplicationError, MacOsError, NotificationError}; |
| 11 | |
| 12 | #[cfg(all(target_os = "macos", feature = "preview-macos-un"))] |
| 13 | pub use craterust-analyzer cargo notify-rust 4.18.0 crate/::macos::MacOsError; |
| 14 | |
| 15 | /// The Error type. |
| 16 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 17 | pub struct Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 18 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#, |
| 19 | } |
| 20 | |
| 21 | /// The kind of an error used by [`Error`]. |
| 22 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)] |
| 23 | #[non_exhaustive] |
| 24 | pub enum ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind# { |
| 25 | /// Only here for backwards compatibility. |
| 26 | Msgrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Msg#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 27 | |
| 28 | #[cfg(all(feature = "dbus", unix, not(target_os = "macos")))] |
| 29 | Dbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Dbus#(dbusrust-analyzer cargo dbus 0.9.12 crate/::Errorrust-analyzer cargo dbus 0.9.12 error/Error#), |
| 30 | |
| 31 | #[cfg(all(feature = "zbus", unix, not(target_os = "macos")))] |
| 32 | Zbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Zbus#(zbusrust-analyzer cargo zbus 5.19.0 crate/::Errorrust-analyzer cargo zbus 5.19.0 error/Error#), |
| 33 | |
| 34 | #[cfg(target_os = "macos")] |
| 35 | MacNotificationSys(mac_notification_sys::error::Error), |
| 36 | |
| 37 | #[cfg(all(target_os = "macos", feature = "preview-macos-un"))] |
| 38 | MacUserNotifications(mac_usernotifications::Error), |
| 39 | |
| 40 | Parserust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Parse#(numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#), |
| 41 | |
| 42 | SpecVersionrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#SpecVersion#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 43 | |
| 44 | Conversionrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Conversion#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#), |
| 45 | |
| 46 | #[cfg(all(feature = "images_no_default_features", unix, not(target_os = "macos")))] |
| 47 | Imagerust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Image#(ImageErrorrust-analyzer cargo notify-rust 4.18.0 image/ImageError#), |
| 48 | |
| 49 | ImplementationMissingrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#ImplementationMissing#, |
| 50 | } |
| 51 | |
| 52 | impl fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 53 | fn fmtrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][Display]fmt().(&self, f: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# { |
| 54 | match self.kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind. { |
| 55 | #[cfg(all(feature = "dbus", unix, not(target_os = "macos")))] |
| 56 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Dbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Dbus#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", e), |
| 57 | |
| 58 | #[cfg(all(feature = "zbus", unix, not(target_os = "macos")))] |
| 59 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Zbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Zbus#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", e), |
| 60 | |
| 61 | #[cfg(target_os = "macos")] |
| 62 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::MacNotificationSys(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{e}"), |
| 63 | |
| 64 | #[cfg(all(target_os = "macos", feature = "preview-macos-un"))] |
| 65 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::MacUserNotifications(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{e}"), |
| 66 | |
| 67 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Parserust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Parse#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Parsing Error: {e}"), |
| 68 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Conversionrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Conversion#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "Conversion Error: {e}"), |
| 69 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::SpecVersionrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#SpecVersion#(ref e) | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Msgrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Msg#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{e}"), |
| 70 | #[cfg(all(feature = "images_no_default_features", unix, not(target_os = "macos")))] |
| 71 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Imagerust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Image#(ref e) => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "{}", e), |
| 72 | ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::ImplementationMissingrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#ImplementationMissing# => writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!( |
| 73 | f, |
| 74 | r#"No Dbus implementation available, please compile with either feature ="z" or feature="d""# |
| 75 | ), |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# {} |
| 81 | |
| 82 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&str> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 83 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<&str>`]from().(e: &str) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 84 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 85 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Msgrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Msg#(e.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | #[cfg(all(feature = "dbus", unix, not(target_os = "macos")))] |
| 91 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<dbusrust-analyzer cargo dbus 0.9.12 crate/::Errorrust-analyzer cargo dbus 0.9.12 error/Error#> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 92 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<dbus::Error>`]from().(e: dbusrust-analyzer cargo dbus 0.9.12 crate/::Errorrust-analyzer cargo dbus 0.9.12 error/Error#) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 93 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 94 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Dbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Dbus#(e), |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | #[cfg(all(feature = "zbus", unix, not(target_os = "macos")))] |
| 100 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<zbusrust-analyzer cargo zbus 5.19.0 crate/::Errorrust-analyzer cargo zbus 5.19.0 error/Error#> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 101 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<zbus::Error>`]from().(e: zbusrust-analyzer cargo zbus 5.19.0 crate/::Errorrust-analyzer cargo zbus 5.19.0 error/Error#) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 102 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 103 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Zbusrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Zbus#(e), |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | #[cfg(target_os = "macos")] |
| 109 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mac_notification_sys::error::Error> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 110 | fn from(e: mac_notification_sys::error::Error) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 111 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 112 | kind: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::MacNotificationSys(e), |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | #[cfg(all(feature = "images_no_default_features", unix, not(target_os = "macos")))] |
| 118 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ImageErrorrust-analyzer cargo notify-rust 4.18.0 image/ImageError#> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 119 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<ImageError>`]from().(e: ImageErrorrust-analyzer cargo notify-rust 4.18.0 image/ImageError#) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 120 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 121 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Imagerust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Image#(e), |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | #[cfg(all(target_os = "macos", feature = "preview-macos-un"))] |
| 127 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<mac_usernotifications::Error> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 128 | fn from(e: mac_usernotifications::Error) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 129 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 130 | kind: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::MacUserNotifications(e), |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 136 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<num::ParseIntError>`]from().(e: numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::ParseIntErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/error/ParseIntError#) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 137 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 138 | kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind.: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::Parserust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#Parse#(e), |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#> for Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 144 | fn fromrust-analyzer cargo notify-rust 4.18.0 error/impl#[Error][`From<ErrorKind>`]from().(kind: ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#) -> Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { |
| 145 | Errorrust-analyzer cargo notify-rust 4.18.0 error/Error# { kindrust-analyzer cargo notify-rust 4.18.0 error/Error#kind. } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /// Just the usual bail macro |
| 150 | #[macro_export] |
| 151 | #[doc(hidden)] |
| 152 | macro_rules! bailrust-analyzer cargo notify-rust 4.18.0 error/bail! { |
| 153 | ($e:expr) => { |
| 154 | return Err($e.into()); |
| 155 | }; |
| 156 | ($fmt:expr, $($arg:tt)+) => { |
| 157 | return Err(format!($fmt, $($arg)+).into()); |
| 158 | }; |
| 159 | } |
| 160 | |
| 161 | /// Exits a function early with an `Error` if the condition is not satisfied. |
| 162 | /// |
| 163 | /// Similar to `assert!`, `ensure!` takes a condition and exits the function |
| 164 | /// if the condition fails. Unlike `assert!`, `ensure!` returns an `Error`, |
| 165 | /// it does not panic. |
| 166 | #[macro_export(local_inner_macros)] |
| 167 | #[doc(hidden)] |
| 168 | macro_rules! ensurerust-analyzer cargo notify-rust 4.18.0 error/ensure! { |
| 169 | ($cond:expr, $e:expr) => { |
| 170 | if !($cond) { |
| 171 | bail!($e); |
| 172 | } |
| 173 | }; |
| 174 | ($cond:expr, $fmt:expr, $($arg:tt)*) => { |
| 175 | if !($cond) { |
| 176 | bail!($fmt, $($arg)*); |
| 177 | } |
| 178 | }; |
| 179 | } |