rust_macios/user_notifications/
un_time_interval_notification_trigger.rs1use objc::{msg_send, sel, sel_impl};
2use rust_macios_objective_c_runtime_proc_macros::interface_impl;
3
4use crate::{
5 foundation::{NSDate, NSTimeInterval},
6 object,
7 objective_c_runtime::traits::FromId,
8 utils::to_optional,
9};
10
11use super::IUNNotificationTrigger;
12
13object! {
14 unsafe pub struct UNTimeIntervalNotificationTrigger;
16}
17
18impl IUNNotificationTrigger for UNTimeIntervalNotificationTrigger {}
19
20#[interface_impl(UNNotificationTrigger)]
21impl UNTimeIntervalNotificationTrigger {
22 #[method]
27 pub fn trigger_with_time_interval_repeats(time_interval: NSTimeInterval, repeats: bool) -> Self
28 where
29 Self: Sized + FromId,
30 {
31 unsafe {
32 Self::from_id(msg_send![
33 Self::m_class(),
34 triggerWithTimeInterval: time_interval
35 repeats: repeats
36 ])
37 }
38 }
39
40 #[method]
45 pub fn next_trigger_date(&self) -> Option<NSDate> {
46 unsafe { to_optional(msg_send![self.m_self(), nextTriggerDate]) }
47 }
48
49 #[property]
51 pub fn time_interval(&self) -> NSTimeInterval {
52 unsafe { msg_send![self.m_self(), timeInterval] }
53 }
54}