objc2_foundation/generated/
NSLock.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
9extern_protocol!(
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslocking?language=objc)
11    pub unsafe trait NSLocking {
12        #[unsafe(method(lock))]
13        #[unsafe(method_family = none)]
14        unsafe fn lock(&self);
15
16        #[unsafe(method(unlock))]
17        #[unsafe(method_family = none)]
18        unsafe fn unlock(&self);
19    }
20);
21
22extern_class!(
23    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslock?language=objc)
24    #[unsafe(super(NSObject))]
25    #[derive(Debug, PartialEq, Eq, Hash)]
26    pub struct NSLock;
27);
28
29unsafe impl Send for NSLock {}
30
31unsafe impl Sync for NSLock {}
32
33unsafe impl NSLocking for NSLock {}
34
35unsafe impl NSObjectProtocol for NSLock {}
36
37impl NSLock {
38    extern_methods!(
39        #[unsafe(method(tryLock))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn tryLock(&self) -> bool;
42
43        #[cfg(feature = "NSDate")]
44        #[unsafe(method(lockBeforeDate:))]
45        #[unsafe(method_family = none)]
46        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
47
48        #[cfg(feature = "NSString")]
49        #[unsafe(method(name))]
50        #[unsafe(method_family = none)]
51        pub fn name(&self) -> Option<Retained<NSString>>;
52
53        #[cfg(feature = "NSString")]
54        /// Setter for [`name`][Self::name].
55        #[unsafe(method(setName:))]
56        #[unsafe(method_family = none)]
57        pub fn setName(&self, name: Option<&NSString>);
58    );
59}
60
61/// Methods declared on superclass `NSObject`.
62impl NSLock {
63    extern_methods!(
64        #[unsafe(method(init))]
65        #[unsafe(method_family = init)]
66        pub fn init(this: Allocated<Self>) -> Retained<Self>;
67
68        #[unsafe(method(new))]
69        #[unsafe(method_family = new)]
70        pub fn new() -> Retained<Self>;
71    );
72}
73
74impl DefaultRetained for NSLock {
75    #[inline]
76    fn default_retained() -> Retained<Self> {
77        Self::new()
78    }
79}
80
81extern_class!(
82    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsconditionlock?language=objc)
83    #[unsafe(super(NSObject))]
84    #[derive(Debug, PartialEq, Eq, Hash)]
85    pub struct NSConditionLock;
86);
87
88unsafe impl Send for NSConditionLock {}
89
90unsafe impl Sync for NSConditionLock {}
91
92unsafe impl NSLocking for NSConditionLock {}
93
94unsafe impl NSObjectProtocol for NSConditionLock {}
95
96impl NSConditionLock {
97    extern_methods!(
98        #[unsafe(method(initWithCondition:))]
99        #[unsafe(method_family = init)]
100        pub unsafe fn initWithCondition(
101            this: Allocated<Self>,
102            condition: NSInteger,
103        ) -> Retained<Self>;
104
105        #[unsafe(method(condition))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn condition(&self) -> NSInteger;
108
109        #[unsafe(method(lockWhenCondition:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn lockWhenCondition(&self, condition: NSInteger);
112
113        #[unsafe(method(tryLock))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn tryLock(&self) -> bool;
116
117        #[unsafe(method(tryLockWhenCondition:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn tryLockWhenCondition(&self, condition: NSInteger) -> bool;
120
121        #[unsafe(method(unlockWithCondition:))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn unlockWithCondition(&self, condition: NSInteger);
124
125        #[cfg(feature = "NSDate")]
126        #[unsafe(method(lockBeforeDate:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
129
130        #[cfg(feature = "NSDate")]
131        #[unsafe(method(lockWhenCondition:beforeDate:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn lockWhenCondition_beforeDate(
134            &self,
135            condition: NSInteger,
136            limit: &NSDate,
137        ) -> bool;
138
139        #[cfg(feature = "NSString")]
140        #[unsafe(method(name))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
143
144        #[cfg(feature = "NSString")]
145        /// Setter for [`name`][Self::name].
146        #[unsafe(method(setName:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setName(&self, name: Option<&NSString>);
149    );
150}
151
152/// Methods declared on superclass `NSObject`.
153impl NSConditionLock {
154    extern_methods!(
155        #[unsafe(method(init))]
156        #[unsafe(method_family = init)]
157        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
158
159        #[unsafe(method(new))]
160        #[unsafe(method_family = new)]
161        pub unsafe fn new() -> Retained<Self>;
162    );
163}
164
165extern_class!(
166    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrecursivelock?language=objc)
167    #[unsafe(super(NSObject))]
168    #[derive(Debug, PartialEq, Eq, Hash)]
169    pub struct NSRecursiveLock;
170);
171
172unsafe impl Send for NSRecursiveLock {}
173
174unsafe impl Sync for NSRecursiveLock {}
175
176unsafe impl NSLocking for NSRecursiveLock {}
177
178unsafe impl NSObjectProtocol for NSRecursiveLock {}
179
180impl NSRecursiveLock {
181    extern_methods!(
182        #[unsafe(method(tryLock))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn tryLock(&self) -> bool;
185
186        #[cfg(feature = "NSDate")]
187        #[unsafe(method(lockBeforeDate:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn lockBeforeDate(&self, limit: &NSDate) -> bool;
190
191        #[cfg(feature = "NSString")]
192        #[unsafe(method(name))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
195
196        #[cfg(feature = "NSString")]
197        /// Setter for [`name`][Self::name].
198        #[unsafe(method(setName:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn setName(&self, name: Option<&NSString>);
201    );
202}
203
204/// Methods declared on superclass `NSObject`.
205impl NSRecursiveLock {
206    extern_methods!(
207        #[unsafe(method(init))]
208        #[unsafe(method_family = init)]
209        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
210
211        #[unsafe(method(new))]
212        #[unsafe(method_family = new)]
213        pub unsafe fn new() -> Retained<Self>;
214    );
215}
216
217extern_class!(
218    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nscondition?language=objc)
219    #[unsafe(super(NSObject))]
220    #[derive(Debug, PartialEq, Eq, Hash)]
221    pub struct NSCondition;
222);
223
224unsafe impl Send for NSCondition {}
225
226unsafe impl Sync for NSCondition {}
227
228unsafe impl NSLocking for NSCondition {}
229
230unsafe impl NSObjectProtocol for NSCondition {}
231
232impl NSCondition {
233    extern_methods!(
234        #[unsafe(method(wait))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn wait(&self);
237
238        #[cfg(feature = "NSDate")]
239        #[unsafe(method(waitUntilDate:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn waitUntilDate(&self, limit: &NSDate) -> bool;
242
243        #[unsafe(method(signal))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn signal(&self);
246
247        #[unsafe(method(broadcast))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn broadcast(&self);
250
251        #[cfg(feature = "NSString")]
252        #[unsafe(method(name))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn name(&self) -> Option<Retained<NSString>>;
255
256        #[cfg(feature = "NSString")]
257        /// Setter for [`name`][Self::name].
258        #[unsafe(method(setName:))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn setName(&self, name: Option<&NSString>);
261    );
262}
263
264/// Methods declared on superclass `NSObject`.
265impl NSCondition {
266    extern_methods!(
267        #[unsafe(method(init))]
268        #[unsafe(method_family = init)]
269        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
270
271        #[unsafe(method(new))]
272        #[unsafe(method_family = new)]
273        pub unsafe fn new() -> Retained<Self>;
274    );
275}