rust_macios/background_tasks/
bg_processing_task_request.rs1use objc::{msg_send, sel, sel_impl};
2
3use crate::{
4 foundation::NSString,
5 object,
6 objective_c_runtime::{
7 macros::interface_impl,
8 traits::{FromId, PNSObject},
9 },
10 utils::to_bool,
11};
12
13use super::IBGTaskRequest;
14
15object! {
16 unsafe pub struct BGProcessingTaskRequest;
18}
19
20#[interface_impl(BGTaskRequest)]
21impl BGProcessingTaskRequest {
22 #[method]
27 pub fn init_with_identifier(&mut self, identifier: NSString) -> Self
28 where
29 Self: Sized + FromId,
30 {
31 unsafe { Self::from_id(msg_send![self.m_self(), initWithIdentifier: identifier]) }
32 }
33
34 #[property]
39 pub fn requires_external_power() -> bool {
40 unsafe { to_bool(msg_send![Self::m_class(), requiresExternalPower]) }
41 }
42
43 #[property]
45 pub fn requires_network_connectivity() -> bool {
46 unsafe { to_bool(msg_send![Self::m_class(), requiresNetworkConnectivity]) }
47 }
48}
49
50impl IBGTaskRequest for BGProcessingTaskRequest {}
51
52impl Default for BGProcessingTaskRequest {
53 fn default() -> Self {
54 Self::m_new()
55 }
56}