objc2_foundation/generated/
NSDistributedNotificationCenter.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationcentertype?language=objc)
10// NS_TYPED_EXTENSIBLE_ENUM
11#[cfg(feature = "NSString")]
12pub type NSDistributedNotificationCenterType = NSString;
13
14extern "C" {
15    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslocalnotificationcentertype?language=objc)
16    #[cfg(feature = "NSString")]
17    pub static NSLocalNotificationCenterType: &'static NSDistributedNotificationCenterType;
18}
19
20/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationsuspensionbehavior?language=objc)
21// NS_ENUM
22#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct NSNotificationSuspensionBehavior(pub NSUInteger);
25impl NSNotificationSuspensionBehavior {
26    #[doc(alias = "NSNotificationSuspensionBehaviorDrop")]
27    pub const Drop: Self = Self(1);
28    #[doc(alias = "NSNotificationSuspensionBehaviorCoalesce")]
29    pub const Coalesce: Self = Self(2);
30    #[doc(alias = "NSNotificationSuspensionBehaviorHold")]
31    pub const Hold: Self = Self(3);
32    #[doc(alias = "NSNotificationSuspensionBehaviorDeliverImmediately")]
33    pub const DeliverImmediately: Self = Self(4);
34}
35
36unsafe impl Encode for NSNotificationSuspensionBehavior {
37    const ENCODING: Encoding = NSUInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSNotificationSuspensionBehavior {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationoptions?language=objc)
45// NS_OPTIONS
46#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSDistributedNotificationOptions(pub NSUInteger);
49bitflags::bitflags! {
50    impl NSDistributedNotificationOptions: NSUInteger {
51        #[doc(alias = "NSDistributedNotificationDeliverImmediately")]
52        const DeliverImmediately = 1<<0;
53        #[doc(alias = "NSDistributedNotificationPostToAllSessions")]
54        const PostToAllSessions = 1<<1;
55    }
56}
57
58unsafe impl Encode for NSDistributedNotificationOptions {
59    const ENCODING: Encoding = NSUInteger::ENCODING;
60}
61
62unsafe impl RefEncode for NSDistributedNotificationOptions {
63    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
64}
65
66/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationdeliverimmediately?language=objc)
67pub static NSNotificationDeliverImmediately: NSDistributedNotificationOptions =
68    NSDistributedNotificationOptions(NSDistributedNotificationOptions::DeliverImmediately.0);
69
70/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnotificationposttoallsessions?language=objc)
71pub static NSNotificationPostToAllSessions: NSDistributedNotificationOptions =
72    NSDistributedNotificationOptions(NSDistributedNotificationOptions::PostToAllSessions.0);
73
74extern_class!(
75    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdistributednotificationcenter?language=objc)
76    #[unsafe(super(NSNotificationCenter, NSObject))]
77    #[derive(Debug, PartialEq, Eq, Hash)]
78    #[cfg(feature = "NSNotification")]
79    pub struct NSDistributedNotificationCenter;
80);
81
82#[cfg(feature = "NSNotification")]
83unsafe impl NSObjectProtocol for NSDistributedNotificationCenter {}
84
85#[cfg(feature = "NSNotification")]
86impl NSDistributedNotificationCenter {
87    extern_methods!(
88        #[cfg(feature = "NSString")]
89        #[unsafe(method(notificationCenterForType:))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn notificationCenterForType(
92            notification_center_type: &NSDistributedNotificationCenterType,
93        ) -> Retained<NSDistributedNotificationCenter>;
94
95        #[unsafe(method(defaultCenter))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn defaultCenter() -> Retained<NSDistributedNotificationCenter>;
98
99        #[cfg(feature = "NSString")]
100        #[unsafe(method(addObserver:selector:name:object:suspensionBehavior:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn addObserver_selector_name_object_suspensionBehavior(
103            &self,
104            observer: &AnyObject,
105            selector: Sel,
106            name: Option<&NSNotificationName>,
107            object: Option<&NSString>,
108            suspension_behavior: NSNotificationSuspensionBehavior,
109        );
110
111        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
112        #[unsafe(method(postNotificationName:object:userInfo:deliverImmediately:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn postNotificationName_object_userInfo_deliverImmediately(
115            &self,
116            name: &NSNotificationName,
117            object: Option<&NSString>,
118            user_info: Option<&NSDictionary>,
119            deliver_immediately: bool,
120        );
121
122        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
123        #[unsafe(method(postNotificationName:object:userInfo:options:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn postNotificationName_object_userInfo_options(
126            &self,
127            name: &NSNotificationName,
128            object: Option<&NSString>,
129            user_info: Option<&NSDictionary>,
130            options: NSDistributedNotificationOptions,
131        );
132
133        #[unsafe(method(suspended))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn suspended(&self) -> bool;
136
137        /// Setter for [`suspended`][Self::suspended].
138        #[unsafe(method(setSuspended:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setSuspended(&self, suspended: bool);
141
142        #[cfg(feature = "NSString")]
143        #[unsafe(method(addObserver:selector:name:object:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn addObserver_selector_name_object(
146            &self,
147            observer: &AnyObject,
148            a_selector: Sel,
149            a_name: Option<&NSNotificationName>,
150            an_object: Option<&NSString>,
151        );
152
153        #[cfg(feature = "NSString")]
154        #[unsafe(method(postNotificationName:object:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn postNotificationName_object(
157            &self,
158            a_name: &NSNotificationName,
159            an_object: Option<&NSString>,
160        );
161
162        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
163        #[unsafe(method(postNotificationName:object:userInfo:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn postNotificationName_object_userInfo(
166            &self,
167            a_name: &NSNotificationName,
168            an_object: Option<&NSString>,
169            a_user_info: Option<&NSDictionary>,
170        );
171
172        #[cfg(feature = "NSString")]
173        #[unsafe(method(removeObserver:name:object:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn removeObserver_name_object(
176            &self,
177            observer: &AnyObject,
178            a_name: Option<&NSNotificationName>,
179            an_object: Option<&NSString>,
180        );
181    );
182}
183
184/// Methods declared on superclass `NSObject`.
185#[cfg(feature = "NSNotification")]
186impl NSDistributedNotificationCenter {
187    extern_methods!(
188        #[unsafe(method(init))]
189        #[unsafe(method_family = init)]
190        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
191
192        #[unsafe(method(new))]
193        #[unsafe(method_family = new)]
194        pub unsafe fn new() -> Retained<Self>;
195    );
196}