objc2_foundation/generated/
NSPort.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/nssocketnativehandle?language=objc)
10pub type NSSocketNativeHandle = c_int;
11
12extern "C" {
13    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsportdidbecomeinvalidnotification?language=objc)
14    #[cfg(all(feature = "NSNotification", feature = "NSString"))]
15    pub static NSPortDidBecomeInvalidNotification: &'static NSNotificationName;
16}
17
18extern_class!(
19    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsport?language=objc)
20    #[unsafe(super(NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct NSPort;
23);
24
25#[cfg(feature = "NSObject")]
26extern_conformance!(
27    unsafe impl NSCoding for NSPort {}
28);
29
30#[cfg(feature = "NSObject")]
31extern_conformance!(
32    unsafe impl NSCopying for NSPort {}
33);
34
35#[cfg(feature = "NSObject")]
36unsafe impl CopyingHelper for NSPort {
37    type Result = Self;
38}
39
40extern_conformance!(
41    unsafe impl NSObjectProtocol for NSPort {}
42);
43
44impl NSPort {
45    extern_methods!(
46        #[unsafe(method(port))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn port() -> Retained<NSPort>;
49
50        #[unsafe(method(invalidate))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn invalidate(&self);
53
54        #[unsafe(method(isValid))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn isValid(&self) -> bool;
57
58        #[unsafe(method(setDelegate:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn setDelegate(&self, an_object: Option<&ProtocolObject<dyn NSPortDelegate>>);
61
62        #[unsafe(method(delegate))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSPortDelegate>>>;
65
66        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
67        #[unsafe(method(scheduleInRunLoop:forMode:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn scheduleInRunLoop_forMode(&self, run_loop: &NSRunLoop, mode: &NSRunLoopMode);
70
71        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
72        #[unsafe(method(removeFromRunLoop:forMode:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn removeFromRunLoop_forMode(&self, run_loop: &NSRunLoop, mode: &NSRunLoopMode);
75
76        #[unsafe(method(reservedSpaceLength))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn reservedSpaceLength(&self) -> NSUInteger;
79
80        #[cfg(all(feature = "NSArray", feature = "NSDate"))]
81        #[unsafe(method(sendBeforeDate:components:from:reserved:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn sendBeforeDate_components_from_reserved(
84            &self,
85            limit_date: &NSDate,
86            components: Option<&NSMutableArray>,
87            receive_port: Option<&NSPort>,
88            header_space_reserved: NSUInteger,
89        ) -> bool;
90
91        #[cfg(all(feature = "NSArray", feature = "NSDate"))]
92        #[unsafe(method(sendBeforeDate:msgid:components:from:reserved:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn sendBeforeDate_msgid_components_from_reserved(
95            &self,
96            limit_date: &NSDate,
97            msg_id: NSUInteger,
98            components: Option<&NSMutableArray>,
99            receive_port: Option<&NSPort>,
100            header_space_reserved: NSUInteger,
101        ) -> bool;
102
103        #[cfg(all(
104            feature = "NSConnection",
105            feature = "NSObjCRuntime",
106            feature = "NSRunLoop",
107            feature = "NSString"
108        ))]
109        #[deprecated = "Use NSXPCConnection instead"]
110        #[unsafe(method(addConnection:toRunLoop:forMode:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn addConnection_toRunLoop_forMode(
113            &self,
114            conn: &NSConnection,
115            run_loop: &NSRunLoop,
116            mode: &NSRunLoopMode,
117        );
118
119        #[cfg(all(
120            feature = "NSConnection",
121            feature = "NSObjCRuntime",
122            feature = "NSRunLoop",
123            feature = "NSString"
124        ))]
125        #[deprecated = "Use NSXPCConnection instead"]
126        #[unsafe(method(removeConnection:fromRunLoop:forMode:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn removeConnection_fromRunLoop_forMode(
129            &self,
130            conn: &NSConnection,
131            run_loop: &NSRunLoop,
132            mode: &NSRunLoopMode,
133        );
134    );
135}
136
137/// Methods declared on superclass `NSObject`.
138impl NSPort {
139    extern_methods!(
140        #[unsafe(method(init))]
141        #[unsafe(method_family = init)]
142        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
143
144        #[unsafe(method(new))]
145        #[unsafe(method_family = new)]
146        pub unsafe fn new() -> Retained<Self>;
147    );
148}
149
150extern_protocol!(
151    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsportdelegate?language=objc)
152    pub unsafe trait NSPortDelegate: NSObjectProtocol {
153        #[cfg(feature = "NSPortMessage")]
154        #[optional]
155        #[unsafe(method(handlePortMessage:))]
156        #[unsafe(method_family = none)]
157        unsafe fn handlePortMessage(&self, message: &NSPortMessage);
158    }
159);
160
161/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmachportoptions?language=objc)
162// NS_OPTIONS
163#[repr(transparent)]
164#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
165pub struct NSMachPortOptions(pub NSUInteger);
166bitflags::bitflags! {
167    impl NSMachPortOptions: NSUInteger {
168        #[doc(alias = "NSMachPortDeallocateNone")]
169        const DeallocateNone = 0;
170        #[doc(alias = "NSMachPortDeallocateSendRight")]
171        const DeallocateSendRight = 1<<0;
172        #[doc(alias = "NSMachPortDeallocateReceiveRight")]
173        const DeallocateReceiveRight = 1<<1;
174    }
175}
176
177unsafe impl Encode for NSMachPortOptions {
178    const ENCODING: Encoding = NSUInteger::ENCODING;
179}
180
181unsafe impl RefEncode for NSMachPortOptions {
182    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
183}
184
185extern_class!(
186    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmachport?language=objc)
187    #[unsafe(super(NSPort, NSObject))]
188    #[derive(Debug, PartialEq, Eq, Hash)]
189    pub struct NSMachPort;
190);
191
192#[cfg(feature = "NSObject")]
193extern_conformance!(
194    unsafe impl NSCoding for NSMachPort {}
195);
196
197#[cfg(feature = "NSObject")]
198extern_conformance!(
199    unsafe impl NSCopying for NSMachPort {}
200);
201
202#[cfg(feature = "NSObject")]
203unsafe impl CopyingHelper for NSMachPort {
204    type Result = Self;
205}
206
207extern_conformance!(
208    unsafe impl NSObjectProtocol for NSMachPort {}
209);
210
211impl NSMachPort {
212    extern_methods!(
213        #[unsafe(method(portWithMachPort:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn portWithMachPort(mach_port: u32) -> Retained<NSPort>;
216
217        #[unsafe(method(initWithMachPort:))]
218        #[unsafe(method_family = init)]
219        pub unsafe fn initWithMachPort(this: Allocated<Self>, mach_port: u32) -> Retained<Self>;
220
221        #[unsafe(method(setDelegate:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn setDelegate(
224            &self,
225            an_object: Option<&ProtocolObject<dyn NSMachPortDelegate>>,
226        );
227
228        #[unsafe(method(delegate))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSMachPortDelegate>>>;
231
232        #[unsafe(method(portWithMachPort:options:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn portWithMachPort_options(
235            mach_port: u32,
236            f: NSMachPortOptions,
237        ) -> Retained<NSPort>;
238
239        #[unsafe(method(initWithMachPort:options:))]
240        #[unsafe(method_family = init)]
241        pub unsafe fn initWithMachPort_options(
242            this: Allocated<Self>,
243            mach_port: u32,
244            f: NSMachPortOptions,
245        ) -> Retained<Self>;
246
247        #[unsafe(method(machPort))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn machPort(&self) -> u32;
250
251        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
252        #[unsafe(method(scheduleInRunLoop:forMode:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn scheduleInRunLoop_forMode(&self, run_loop: &NSRunLoop, mode: &NSRunLoopMode);
255
256        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
257        #[unsafe(method(removeFromRunLoop:forMode:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn removeFromRunLoop_forMode(&self, run_loop: &NSRunLoop, mode: &NSRunLoopMode);
260    );
261}
262
263/// Methods declared on superclass `NSObject`.
264impl NSMachPort {
265    extern_methods!(
266        #[unsafe(method(init))]
267        #[unsafe(method_family = init)]
268        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
269
270        #[unsafe(method(new))]
271        #[unsafe(method_family = new)]
272        pub unsafe fn new() -> Retained<Self>;
273    );
274}
275
276extern_protocol!(
277    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmachportdelegate?language=objc)
278    pub unsafe trait NSMachPortDelegate: NSPortDelegate {
279        #[optional]
280        #[unsafe(method(handleMachMessage:))]
281        #[unsafe(method_family = none)]
282        unsafe fn handleMachMessage(&self, msg: NonNull<c_void>);
283    }
284);
285
286extern_class!(
287    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsmessageport?language=objc)
288    #[unsafe(super(NSPort, NSObject))]
289    #[derive(Debug, PartialEq, Eq, Hash)]
290    pub struct NSMessagePort;
291);
292
293#[cfg(feature = "NSObject")]
294extern_conformance!(
295    unsafe impl NSCoding for NSMessagePort {}
296);
297
298#[cfg(feature = "NSObject")]
299extern_conformance!(
300    unsafe impl NSCopying for NSMessagePort {}
301);
302
303#[cfg(feature = "NSObject")]
304unsafe impl CopyingHelper for NSMessagePort {
305    type Result = Self;
306}
307
308extern_conformance!(
309    unsafe impl NSObjectProtocol for NSMessagePort {}
310);
311
312impl NSMessagePort {
313    extern_methods!();
314}
315
316/// Methods declared on superclass `NSObject`.
317impl NSMessagePort {
318    extern_methods!(
319        #[unsafe(method(init))]
320        #[unsafe(method_family = init)]
321        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
322
323        #[unsafe(method(new))]
324        #[unsafe(method_family = new)]
325        pub unsafe fn new() -> Retained<Self>;
326    );
327}
328
329extern_class!(
330    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nssocketport?language=objc)
331    #[unsafe(super(NSPort, NSObject))]
332    #[derive(Debug, PartialEq, Eq, Hash)]
333    pub struct NSSocketPort;
334);
335
336#[cfg(feature = "NSObject")]
337extern_conformance!(
338    unsafe impl NSCoding for NSSocketPort {}
339);
340
341#[cfg(feature = "NSObject")]
342extern_conformance!(
343    unsafe impl NSCopying for NSSocketPort {}
344);
345
346#[cfg(feature = "NSObject")]
347unsafe impl CopyingHelper for NSSocketPort {
348    type Result = Self;
349}
350
351extern_conformance!(
352    unsafe impl NSObjectProtocol for NSSocketPort {}
353);
354
355impl NSSocketPort {
356    extern_methods!(
357        #[unsafe(method(init))]
358        #[unsafe(method_family = init)]
359        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
360
361        #[unsafe(method(initWithTCPPort:))]
362        #[unsafe(method_family = init)]
363        pub unsafe fn initWithTCPPort(
364            this: Allocated<Self>,
365            port: c_ushort,
366        ) -> Option<Retained<Self>>;
367
368        #[cfg(feature = "NSData")]
369        #[unsafe(method(initWithProtocolFamily:socketType:protocol:address:))]
370        #[unsafe(method_family = init)]
371        pub unsafe fn initWithProtocolFamily_socketType_protocol_address(
372            this: Allocated<Self>,
373            family: c_int,
374            r#type: c_int,
375            protocol: c_int,
376            address: &NSData,
377        ) -> Option<Retained<Self>>;
378
379        #[unsafe(method(initWithProtocolFamily:socketType:protocol:socket:))]
380        #[unsafe(method_family = init)]
381        pub unsafe fn initWithProtocolFamily_socketType_protocol_socket(
382            this: Allocated<Self>,
383            family: c_int,
384            r#type: c_int,
385            protocol: c_int,
386            sock: NSSocketNativeHandle,
387        ) -> Option<Retained<Self>>;
388
389        #[cfg(feature = "NSString")]
390        #[unsafe(method(initRemoteWithTCPPort:host:))]
391        #[unsafe(method_family = init)]
392        pub unsafe fn initRemoteWithTCPPort_host(
393            this: Allocated<Self>,
394            port: c_ushort,
395            host_name: Option<&NSString>,
396        ) -> Option<Retained<Self>>;
397
398        #[cfg(feature = "NSData")]
399        #[unsafe(method(initRemoteWithProtocolFamily:socketType:protocol:address:))]
400        #[unsafe(method_family = init)]
401        pub unsafe fn initRemoteWithProtocolFamily_socketType_protocol_address(
402            this: Allocated<Self>,
403            family: c_int,
404            r#type: c_int,
405            protocol: c_int,
406            address: &NSData,
407        ) -> Retained<Self>;
408
409        #[unsafe(method(protocolFamily))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn protocolFamily(&self) -> c_int;
412
413        #[unsafe(method(socketType))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn socketType(&self) -> c_int;
416
417        #[unsafe(method(protocol))]
418        #[unsafe(method_family = none)]
419        pub unsafe fn protocol(&self) -> c_int;
420
421        #[cfg(feature = "NSData")]
422        #[unsafe(method(address))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn address(&self) -> Retained<NSData>;
425
426        #[unsafe(method(socket))]
427        #[unsafe(method_family = none)]
428        pub unsafe fn socket(&self) -> NSSocketNativeHandle;
429    );
430}
431
432/// Methods declared on superclass `NSObject`.
433impl NSSocketPort {
434    extern_methods!(
435        #[unsafe(method(new))]
436        #[unsafe(method_family = new)]
437        pub unsafe fn new() -> Retained<Self>;
438    );
439}