Skip to content

Commit 9276571

Browse files
committed
Update
1 parent b56daf2 commit 9276571

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "win32_notif"
3-
version = "0.4.1"
3+
version = "0.4.2"
44
edition = "2021"
55
description = "Wrapper around Windows UWP XAML (WinRT) Notification api"
66
license = "MIT"

src/structs/handler/activated.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
22

33
use windows::{
4-
core::{Error, IInspectable, Interface, HSTRING},
4+
core::{Error, IInspectable, Interface, Ref, HSTRING},
55
Foundation::{IReference, TypedEventHandler},
66
UI::Notifications::{ToastActivatedEventArgs, ToastNotification},
77
};
@@ -61,7 +61,7 @@ impl NotificationActivatedEventHandler {
6161
mut func: T,
6262
) -> Self {
6363
let handler: TypedEventHandler<ToastNotification, IInspectable> = TypedEventHandler::new(
64-
move |a: &Option<ToastNotification>, b: &Option<IInspectable>| {
64+
move |a: Ref<ToastNotification>, b: Ref<IInspectable>| {
6565
let a = a.as_ref();
6666
let a = a.and_then(|a| PartialNotification { _toast: a }.into());
6767

src/structs/handler/dismissed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use windows::{
2-
core::{Error, Interface},
2+
core::{Error, Interface, Ref},
33
Foundation::TypedEventHandler,
44
UI::Notifications::{ToastDismissalReason, ToastDismissedEventArgs, ToastNotification},
55
};
@@ -48,7 +48,7 @@ impl NotificationDismissedEventHandler {
4848
mut func: T,
4949
) -> Self {
5050
let handler: TypedEventHandler<ToastNotification, ToastDismissedEventArgs> = TypedEventHandler::new(
51-
move |a: &Option<ToastNotification>, b: &Option<ToastDismissedEventArgs>| {
51+
move |a: Ref<ToastNotification>, b: Ref<ToastDismissedEventArgs>| {
5252
let a = a.as_ref();
5353
let a = a.and_then(|a| PartialNotification { _toast: a }.into());
5454

src/structs/handler/failed.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use windows::{
2-
core::{Error, Interface},
2+
core::{Error, Interface, Ref},
33
Foundation::TypedEventHandler,
44
UI::Notifications::{ToastFailedEventArgs, ToastNotification},
55
};
@@ -33,7 +33,7 @@ impl NotificationFailedEventHandler {
3333
mut func: T,
3434
) -> Self {
3535
let handler: TypedEventHandler<ToastNotification, ToastFailedEventArgs> = TypedEventHandler::new(
36-
move |a: &Option<ToastNotification>, b: &Option<ToastFailedEventArgs>| {
36+
move |a: Ref<ToastNotification>, b: Ref<ToastFailedEventArgs>| {
3737
let a = a.as_ref();
3838
let a = a.and_then(|a| PartialNotification { _toast: a }.into());
3939

src/structs/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pub use notification::{Notification, NotificationBuilder};
1010
pub use notifier::ToastsNotifier;
1111
use windows::{
1212
core::HSTRING,
13-
Foundation::EventRegistrationToken,
1413
UI::Notifications::{
1514
NotificationMirroring as ToastNotificationMirroring, ToastNotification,
1615
ToastNotificationPriority,
@@ -151,35 +150,35 @@ impl<T: NotificationImpl> ManageNotification for T {
151150
&self,
152151
handler: NotificationActivatedEventHandler,
153152
) -> Result<i64, NotifError> {
154-
Ok(self.notif().Activated(&handler.handler)?.Value)
153+
Ok(self.notif().Activated(&handler.handler)?)
155154
}
156155
fn remove_activated_handler(&self, token: i64) -> Result<(), NotifError> {
157156
Ok(
158157
self
159158
.notif()
160-
.RemoveActivated(EventRegistrationToken { Value: token })?,
159+
.RemoveActivated(token)?,
161160
)
162161
}
163162

164163
fn set_dismissed_handler(&self, handler: NotificationDismissedEventHandler) -> Result<i64, NotifError> {
165-
Ok(self.notif().Dismissed(&handler.handler)?.Value)
164+
Ok(self.notif().Dismissed(&handler.handler)?)
166165
}
167166
fn remove_dismissed_handler(&self, token: i64) -> Result<(), NotifError> {
168167
Ok(
169168
self
170169
.notif()
171-
.RemoveDismissed(EventRegistrationToken { Value: token })?,
170+
.RemoveDismissed(token)?,
172171
)
173172
}
174173

175174
fn set_failed_handler(&self, handler: NotificationFailedEventHandler) -> Result<i64, NotifError> {
176-
Ok(self.notif().Failed(&handler.handler)?.Value)
175+
Ok(self.notif().Failed(&handler.handler)?)
177176
}
178177
fn remove_failed_handler(&self, token: i64) -> Result<(), NotifError> {
179178
Ok(
180179
self
181180
.notif()
182-
.RemoveFailed(EventRegistrationToken { Value: token })?,
181+
.RemoveFailed(token)?,
183182
)
184183
}
185184

src/structs/notification/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,15 +289,15 @@ impl NotificationBuilder {
289289
let toast = ToastNotification::CreateToastNotification(&doc)?;
290290
if let Some(x) = self.on_activated {
291291
let token = toast.Activated(&x.handler)?;
292-
activated_event_handler_token = Some(token.Value);
292+
activated_event_handler_token = Some(token);
293293
}
294294
if let Some(x) = self.on_dismissed {
295295
let token = toast.Dismissed(&x.handler)?;
296-
dismissed_event_handler_token = Some(token.Value);
296+
dismissed_event_handler_token = Some(token);
297297
}
298298
if let Some(x) = self.on_failed {
299299
let token = toast.Failed(&x.handler)?;
300-
failed_event_handler_token = Some(token.Value);
300+
failed_event_handler_token = Some(token);
301301
}
302302
toast.SetTag(&tag.into())?;
303303
toast.SetGroup(&group.into())?;

0 commit comments

Comments
 (0)