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")]
83extern_conformance!(
84    unsafe impl NSObjectProtocol for NSDistributedNotificationCenter {}
85);
86
87#[cfg(feature = "NSNotification")]
88impl NSDistributedNotificationCenter {
89    extern_methods!(
90        #[cfg(feature = "NSString")]
91        #[unsafe(method(notificationCenterForType:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn notificationCenterForType(
94            notification_center_type: &NSDistributedNotificationCenterType,
95        ) -> Retained<NSDistributedNotificationCenter>;
96
97        #[unsafe(method(defaultCenter))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn defaultCenter() -> Retained<NSDistributedNotificationCenter>;
100
101        #[cfg(feature = "NSString")]
102        #[unsafe(method(addObserver:selector:name:object:suspensionBehavior:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn addObserver_selector_name_object_suspensionBehavior(
105            &self,
106            observer: &AnyObject,
107            selector: Sel,
108            name: Option<&NSNotificationName>,
109            object: Option<&NSString>,
110            suspension_behavior: NSNotificationSuspensionBehavior,
111        );
112
113        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
114        #[unsafe(method(postNotificationName:object:userInfo:deliverImmediately:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn postNotificationName_object_userInfo_deliverImmediately(
117            &self,
118            name: &NSNotificationName,
119            object: Option<&NSString>,
120            user_info: Option<&NSDictionary>,
121            deliver_immediately: bool,
122        );
123
124        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
125        #[unsafe(method(postNotificationName:object:userInfo:options:))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn postNotificationName_object_userInfo_options(
128            &self,
129            name: &NSNotificationName,
130            object: Option<&NSString>,
131            user_info: Option<&NSDictionary>,
132            options: NSDistributedNotificationOptions,
133        );
134
135        #[unsafe(method(suspended))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn suspended(&self) -> bool;
138
139        /// Setter for [`suspended`][Self::suspended].
140        #[unsafe(method(setSuspended:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setSuspended(&self, suspended: bool);
143
144        #[cfg(feature = "NSString")]
145        #[unsafe(method(addObserver:selector:name:object:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn addObserver_selector_name_object(
148            &self,
149            observer: &AnyObject,
150            a_selector: Sel,
151            a_name: Option<&NSNotificationName>,
152            an_object: Option<&NSString>,
153        );
154
155        #[cfg(feature = "NSString")]
156        #[unsafe(method(postNotificationName:object:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn postNotificationName_object(
159            &self,
160            a_name: &NSNotificationName,
161            an_object: Option<&NSString>,
162        );
163
164        #[cfg(all(feature = "NSDictionary", feature = "NSString"))]
165        #[unsafe(method(postNotificationName:object:userInfo:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn postNotificationName_object_userInfo(
168            &self,
169            a_name: &NSNotificationName,
170            an_object: Option<&NSString>,
171            a_user_info: Option<&NSDictionary>,
172        );
173
174        #[cfg(feature = "NSString")]
175        #[unsafe(method(removeObserver:name:object:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn removeObserver_name_object(
178            &self,
179            observer: &AnyObject,
180            a_name: Option<&NSNotificationName>,
181            an_object: Option<&NSString>,
182        );
183    );
184}
185
186/// Methods declared on superclass `NSObject`.
187#[cfg(feature = "NSNotification")]
188impl NSDistributedNotificationCenter {
189    extern_methods!(
190        #[unsafe(method(init))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
193
194        #[unsafe(method(new))]
195        #[unsafe(method_family = new)]
196        pub unsafe fn new() -> Retained<Self>;
197    );
198}