rust_macios/background_tasks/
bg_task_request.rs

1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4    foundation::NSDate,
5    object,
6    objective_c_runtime::{
7        macros::interface_impl,
8        traits::{FromId, PNSObject},
9    },
10};
11
12object! {
13    /// An abstract class for representing task requests.
14    unsafe pub struct BGTaskRequest;
15}
16
17#[interface_impl(NSObject)]
18impl BGTaskRequest {
19    /// The earliest date and time at which to run the task.
20    #[property]
21    pub fn earliest_begin_date(&self) -> NSDate {
22        unsafe { NSDate::from_id(msg_send![self.m_self(), earliestBeginDate]) }
23    }
24
25    /// Sets the earliest date and time at which to run the task.
26    #[property]
27    pub fn set_earliest_begin_date(&mut self, date: NSDate) {
28        unsafe { msg_send![self.m_self(), setEarliestBeginDate: date] }
29    }
30}
31
32impl Default for BGTaskRequest {
33    fn default() -> Self {
34        Self::m_new()
35    }
36}