objc2_foundation/generated/
NSNetServices.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 "C" {
10    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserrorcode?language=objc)
11    #[cfg(feature = "NSString")]
12    pub static NSNetServicesErrorCode: &'static NSString;
13}
14
15extern "C" {
16    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserrordomain?language=objc)
17    #[cfg(all(feature = "NSError", feature = "NSString"))]
18    pub static NSNetServicesErrorDomain: &'static NSErrorDomain;
19}
20
21/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceserror?language=objc)
22// NS_ENUM
23#[repr(transparent)]
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct NSNetServicesError(pub NSInteger);
26impl NSNetServicesError {
27    #[doc(alias = "NSNetServicesUnknownError")]
28    pub const UnknownError: Self = Self(-72000);
29    #[doc(alias = "NSNetServicesCollisionError")]
30    pub const CollisionError: Self = Self(-72001);
31    #[doc(alias = "NSNetServicesNotFoundError")]
32    pub const NotFoundError: Self = Self(-72002);
33    #[doc(alias = "NSNetServicesActivityInProgress")]
34    pub const ActivityInProgress: Self = Self(-72003);
35    #[doc(alias = "NSNetServicesBadArgumentError")]
36    pub const BadArgumentError: Self = Self(-72004);
37    #[doc(alias = "NSNetServicesCancelledError")]
38    pub const CancelledError: Self = Self(-72005);
39    #[doc(alias = "NSNetServicesInvalidError")]
40    pub const InvalidError: Self = Self(-72006);
41    #[doc(alias = "NSNetServicesTimeoutError")]
42    pub const TimeoutError: Self = Self(-72007);
43    #[doc(alias = "NSNetServicesMissingRequiredConfigurationError")]
44    pub const MissingRequiredConfigurationError: Self = Self(-72008);
45}
46
47unsafe impl Encode for NSNetServicesError {
48    const ENCODING: Encoding = NSInteger::ENCODING;
49}
50
51unsafe impl RefEncode for NSNetServicesError {
52    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetserviceoptions?language=objc)
56// NS_OPTIONS
57#[repr(transparent)]
58#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
59pub struct NSNetServiceOptions(pub NSUInteger);
60bitflags::bitflags! {
61    impl NSNetServiceOptions: NSUInteger {
62        #[doc(alias = "NSNetServiceNoAutoRename")]
63        const NoAutoRename = 1<<0;
64        #[doc(alias = "NSNetServiceListenForConnections")]
65        const ListenForConnections = 1<<1;
66    }
67}
68
69unsafe impl Encode for NSNetServiceOptions {
70    const ENCODING: Encoding = NSUInteger::ENCODING;
71}
72
73unsafe impl RefEncode for NSNetServiceOptions {
74    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
75}
76
77extern_class!(
78    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservice?language=objc)
79    #[unsafe(super(NSObject))]
80    #[derive(Debug, PartialEq, Eq, Hash)]
81    #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
82    pub struct NSNetService;
83);
84
85extern_conformance!(
86    unsafe impl NSObjectProtocol for NSNetService {}
87);
88
89impl NSNetService {
90    extern_methods!(
91        #[cfg(feature = "NSString")]
92        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
93        #[unsafe(method(initWithDomain:type:name:port:))]
94        #[unsafe(method_family = init)]
95        pub fn initWithDomain_type_name_port(
96            this: Allocated<Self>,
97            domain: &NSString,
98            r#type: &NSString,
99            name: &NSString,
100            port: c_int,
101        ) -> Retained<Self>;
102
103        #[cfg(feature = "NSString")]
104        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
105        #[unsafe(method(initWithDomain:type:name:))]
106        #[unsafe(method_family = init)]
107        pub fn initWithDomain_type_name(
108            this: Allocated<Self>,
109            domain: &NSString,
110            r#type: &NSString,
111            name: &NSString,
112        ) -> Retained<Self>;
113
114        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
115        /// # Safety
116        ///
117        /// `a_run_loop` possibly has additional threading requirements.
118        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
119        #[unsafe(method(scheduleInRunLoop:forMode:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn scheduleInRunLoop_forMode(
122            &self,
123            a_run_loop: &NSRunLoop,
124            mode: &NSRunLoopMode,
125        );
126
127        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
128        /// # Safety
129        ///
130        /// `a_run_loop` possibly has additional threading requirements.
131        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
132        #[unsafe(method(removeFromRunLoop:forMode:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn removeFromRunLoop_forMode(
135            &self,
136            a_run_loop: &NSRunLoop,
137            mode: &NSRunLoopMode,
138        );
139
140        /// # Safety
141        ///
142        /// This is not retained internally, you must ensure the object is still alive.
143        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
144        #[unsafe(method(delegate))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn delegate(&self)
147            -> Option<Retained<ProtocolObject<dyn NSNetServiceDelegate>>>;
148
149        /// Setter for [`delegate`][Self::delegate].
150        ///
151        /// # Safety
152        ///
153        /// This is unretained, you must ensure the object is kept alive while in use.
154        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
155        #[unsafe(method(setDelegate:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setDelegate(
158            &self,
159            delegate: Option<&ProtocolObject<dyn NSNetServiceDelegate>>,
160        );
161
162        #[unsafe(method(includesPeerToPeer))]
163        #[unsafe(method_family = none)]
164        pub fn includesPeerToPeer(&self) -> bool;
165
166        /// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
167        #[unsafe(method(setIncludesPeerToPeer:))]
168        #[unsafe(method_family = none)]
169        pub fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
170
171        #[cfg(feature = "NSString")]
172        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
173        #[unsafe(method(name))]
174        #[unsafe(method_family = none)]
175        pub fn name(&self) -> Retained<NSString>;
176
177        #[cfg(feature = "NSString")]
178        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
179        #[unsafe(method(type))]
180        #[unsafe(method_family = none)]
181        pub fn r#type(&self) -> Retained<NSString>;
182
183        #[cfg(feature = "NSString")]
184        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
185        #[unsafe(method(domain))]
186        #[unsafe(method_family = none)]
187        pub fn domain(&self) -> Retained<NSString>;
188
189        #[cfg(feature = "NSString")]
190        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
191        #[unsafe(method(hostName))]
192        #[unsafe(method_family = none)]
193        pub fn hostName(&self) -> Option<Retained<NSString>>;
194
195        #[cfg(all(feature = "NSArray", feature = "NSData"))]
196        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
197        #[unsafe(method(addresses))]
198        #[unsafe(method_family = none)]
199        pub fn addresses(&self) -> Option<Retained<NSArray<NSData>>>;
200
201        #[unsafe(method(port))]
202        #[unsafe(method_family = none)]
203        pub fn port(&self) -> NSInteger;
204
205        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
206        #[unsafe(method(publish))]
207        #[unsafe(method_family = none)]
208        pub fn publish(&self);
209
210        #[unsafe(method(publishWithOptions:))]
211        #[unsafe(method_family = none)]
212        pub fn publishWithOptions(&self, options: NSNetServiceOptions);
213
214        #[deprecated = "Not supported"]
215        #[unsafe(method(resolve))]
216        #[unsafe(method_family = none)]
217        pub fn resolve(&self);
218
219        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
220        #[unsafe(method(stop))]
221        #[unsafe(method_family = none)]
222        pub fn stop(&self);
223
224        #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
225        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
226        #[unsafe(method(dictionaryFromTXTRecordData:))]
227        #[unsafe(method_family = none)]
228        pub fn dictionaryFromTXTRecordData(
229            txt_data: &NSData,
230        ) -> Retained<NSDictionary<NSString, NSData>>;
231
232        #[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
233        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
234        #[unsafe(method(dataFromTXTRecordDictionary:))]
235        #[unsafe(method_family = none)]
236        pub fn dataFromTXTRecordDictionary(
237            txt_dictionary: &NSDictionary<NSString, NSData>,
238        ) -> Retained<NSData>;
239
240        #[cfg(feature = "NSDate")]
241        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
242        #[unsafe(method(resolveWithTimeout:))]
243        #[unsafe(method_family = none)]
244        pub fn resolveWithTimeout(&self, timeout: NSTimeInterval);
245
246        #[cfg(feature = "NSStream")]
247        /// # Safety
248        ///
249        /// - `input_stream` must be a valid pointer or null.
250        /// - `output_stream` must be a valid pointer or null.
251        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
252        #[unsafe(method(getInputStream:outputStream:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn getInputStream_outputStream(
255            &self,
256            input_stream: *mut *mut NSInputStream,
257            output_stream: *mut *mut NSOutputStream,
258        ) -> bool;
259
260        #[cfg(feature = "NSData")]
261        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
262        #[unsafe(method(setTXTRecordData:))]
263        #[unsafe(method_family = none)]
264        pub fn setTXTRecordData(&self, record_data: Option<&NSData>) -> bool;
265
266        #[cfg(feature = "NSData")]
267        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
268        #[unsafe(method(TXTRecordData))]
269        #[unsafe(method_family = none)]
270        pub fn TXTRecordData(&self) -> Option<Retained<NSData>>;
271
272        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
273        #[unsafe(method(startMonitoring))]
274        #[unsafe(method_family = none)]
275        pub fn startMonitoring(&self);
276
277        #[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
278        #[unsafe(method(stopMonitoring))]
279        #[unsafe(method_family = none)]
280        pub fn stopMonitoring(&self);
281    );
282}
283
284/// Methods declared on superclass `NSObject`.
285impl NSNetService {
286    extern_methods!(
287        #[unsafe(method(init))]
288        #[unsafe(method_family = init)]
289        pub fn init(this: Allocated<Self>) -> Retained<Self>;
290
291        #[unsafe(method(new))]
292        #[unsafe(method_family = new)]
293        pub fn new() -> Retained<Self>;
294    );
295}
296
297impl DefaultRetained for NSNetService {
298    #[inline]
299    fn default_retained() -> Retained<Self> {
300        Self::new()
301    }
302}
303
304extern_class!(
305    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicebrowser?language=objc)
306    #[unsafe(super(NSObject))]
307    #[derive(Debug, PartialEq, Eq, Hash)]
308    #[deprecated = "Use nw_browser_t in Network framework instead"]
309    pub struct NSNetServiceBrowser;
310);
311
312extern_conformance!(
313    unsafe impl NSObjectProtocol for NSNetServiceBrowser {}
314);
315
316impl NSNetServiceBrowser {
317    extern_methods!(
318        #[deprecated = "Use nw_browser_t in Network framework instead"]
319        #[unsafe(method(init))]
320        #[unsafe(method_family = init)]
321        pub fn init(this: Allocated<Self>) -> Retained<Self>;
322
323        /// # Safety
324        ///
325        /// This is not retained internally, you must ensure the object is still alive.
326        #[deprecated = "Use nw_browser_t in Network framework instead"]
327        #[unsafe(method(delegate))]
328        #[unsafe(method_family = none)]
329        pub unsafe fn delegate(
330            &self,
331        ) -> Option<Retained<ProtocolObject<dyn NSNetServiceBrowserDelegate>>>;
332
333        /// Setter for [`delegate`][Self::delegate].
334        ///
335        /// # Safety
336        ///
337        /// This is unretained, you must ensure the object is kept alive while in use.
338        #[deprecated = "Use nw_browser_t in Network framework instead"]
339        #[unsafe(method(setDelegate:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn setDelegate(
342            &self,
343            delegate: Option<&ProtocolObject<dyn NSNetServiceBrowserDelegate>>,
344        );
345
346        #[unsafe(method(includesPeerToPeer))]
347        #[unsafe(method_family = none)]
348        pub fn includesPeerToPeer(&self) -> bool;
349
350        /// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
351        #[unsafe(method(setIncludesPeerToPeer:))]
352        #[unsafe(method_family = none)]
353        pub fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
354
355        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
356        /// # Safety
357        ///
358        /// `a_run_loop` possibly has additional threading requirements.
359        #[deprecated = "Use nw_browser_t in Network framework instead"]
360        #[unsafe(method(scheduleInRunLoop:forMode:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn scheduleInRunLoop_forMode(
363            &self,
364            a_run_loop: &NSRunLoop,
365            mode: &NSRunLoopMode,
366        );
367
368        #[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
369        /// # Safety
370        ///
371        /// `a_run_loop` possibly has additional threading requirements.
372        #[deprecated = "Use nw_browser_t in Network framework instead"]
373        #[unsafe(method(removeFromRunLoop:forMode:))]
374        #[unsafe(method_family = none)]
375        pub unsafe fn removeFromRunLoop_forMode(
376            &self,
377            a_run_loop: &NSRunLoop,
378            mode: &NSRunLoopMode,
379        );
380
381        #[deprecated = "Use nw_browser_t in Network framework instead"]
382        #[unsafe(method(searchForBrowsableDomains))]
383        #[unsafe(method_family = none)]
384        pub fn searchForBrowsableDomains(&self);
385
386        #[deprecated = "Use nw_browser_t in Network framework instead"]
387        #[unsafe(method(searchForRegistrationDomains))]
388        #[unsafe(method_family = none)]
389        pub fn searchForRegistrationDomains(&self);
390
391        #[cfg(feature = "NSString")]
392        #[deprecated = "Use nw_browser_t in Network framework instead"]
393        #[unsafe(method(searchForServicesOfType:inDomain:))]
394        #[unsafe(method_family = none)]
395        pub fn searchForServicesOfType_inDomain(&self, r#type: &NSString, domain_string: &NSString);
396
397        #[deprecated = "Use nw_browser_t in Network framework instead"]
398        #[unsafe(method(stop))]
399        #[unsafe(method_family = none)]
400        pub fn stop(&self);
401    );
402}
403
404/// Methods declared on superclass `NSObject`.
405impl NSNetServiceBrowser {
406    extern_methods!(
407        #[unsafe(method(new))]
408        #[unsafe(method_family = new)]
409        pub fn new() -> Retained<Self>;
410    );
411}
412
413impl DefaultRetained for NSNetServiceBrowser {
414    #[inline]
415    fn default_retained() -> Retained<Self> {
416        Self::new()
417    }
418}
419
420extern_protocol!(
421    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicedelegate?language=objc)
422    pub unsafe trait NSNetServiceDelegate: NSObjectProtocol {
423        #[optional]
424        #[unsafe(method(netServiceWillPublish:))]
425        #[unsafe(method_family = none)]
426        fn netServiceWillPublish(&self, sender: &NSNetService);
427
428        #[optional]
429        #[unsafe(method(netServiceDidPublish:))]
430        #[unsafe(method_family = none)]
431        fn netServiceDidPublish(&self, sender: &NSNetService);
432
433        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
434        #[optional]
435        #[unsafe(method(netService:didNotPublish:))]
436        #[unsafe(method_family = none)]
437        fn netService_didNotPublish(
438            &self,
439            sender: &NSNetService,
440            error_dict: &NSDictionary<NSString, NSNumber>,
441        );
442
443        #[optional]
444        #[unsafe(method(netServiceWillResolve:))]
445        #[unsafe(method_family = none)]
446        fn netServiceWillResolve(&self, sender: &NSNetService);
447
448        #[optional]
449        #[unsafe(method(netServiceDidResolveAddress:))]
450        #[unsafe(method_family = none)]
451        fn netServiceDidResolveAddress(&self, sender: &NSNetService);
452
453        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
454        #[optional]
455        #[unsafe(method(netService:didNotResolve:))]
456        #[unsafe(method_family = none)]
457        fn netService_didNotResolve(
458            &self,
459            sender: &NSNetService,
460            error_dict: &NSDictionary<NSString, NSNumber>,
461        );
462
463        #[optional]
464        #[unsafe(method(netServiceDidStop:))]
465        #[unsafe(method_family = none)]
466        fn netServiceDidStop(&self, sender: &NSNetService);
467
468        #[cfg(feature = "NSData")]
469        #[optional]
470        #[unsafe(method(netService:didUpdateTXTRecordData:))]
471        #[unsafe(method_family = none)]
472        fn netService_didUpdateTXTRecordData(&self, sender: &NSNetService, data: &NSData);
473
474        #[cfg(feature = "NSStream")]
475        #[optional]
476        #[unsafe(method(netService:didAcceptConnectionWithInputStream:outputStream:))]
477        #[unsafe(method_family = none)]
478        fn netService_didAcceptConnectionWithInputStream_outputStream(
479            &self,
480            sender: &NSNetService,
481            input_stream: &NSInputStream,
482            output_stream: &NSOutputStream,
483        );
484    }
485);
486
487extern_protocol!(
488    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsnetservicebrowserdelegate?language=objc)
489    pub unsafe trait NSNetServiceBrowserDelegate: NSObjectProtocol {
490        #[optional]
491        #[unsafe(method(netServiceBrowserWillSearch:))]
492        #[unsafe(method_family = none)]
493        fn netServiceBrowserWillSearch(&self, browser: &NSNetServiceBrowser);
494
495        #[optional]
496        #[unsafe(method(netServiceBrowserDidStopSearch:))]
497        #[unsafe(method_family = none)]
498        fn netServiceBrowserDidStopSearch(&self, browser: &NSNetServiceBrowser);
499
500        #[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
501        #[optional]
502        #[unsafe(method(netServiceBrowser:didNotSearch:))]
503        #[unsafe(method_family = none)]
504        fn netServiceBrowser_didNotSearch(
505            &self,
506            browser: &NSNetServiceBrowser,
507            error_dict: &NSDictionary<NSString, NSNumber>,
508        );
509
510        #[cfg(feature = "NSString")]
511        #[optional]
512        #[unsafe(method(netServiceBrowser:didFindDomain:moreComing:))]
513        #[unsafe(method_family = none)]
514        fn netServiceBrowser_didFindDomain_moreComing(
515            &self,
516            browser: &NSNetServiceBrowser,
517            domain_string: &NSString,
518            more_coming: bool,
519        );
520
521        #[optional]
522        #[unsafe(method(netServiceBrowser:didFindService:moreComing:))]
523        #[unsafe(method_family = none)]
524        fn netServiceBrowser_didFindService_moreComing(
525            &self,
526            browser: &NSNetServiceBrowser,
527            service: &NSNetService,
528            more_coming: bool,
529        );
530
531        #[cfg(feature = "NSString")]
532        #[optional]
533        #[unsafe(method(netServiceBrowser:didRemoveDomain:moreComing:))]
534        #[unsafe(method_family = none)]
535        fn netServiceBrowser_didRemoveDomain_moreComing(
536            &self,
537            browser: &NSNetServiceBrowser,
538            domain_string: &NSString,
539            more_coming: bool,
540        );
541
542        #[optional]
543        #[unsafe(method(netServiceBrowser:didRemoveService:moreComing:))]
544        #[unsafe(method_family = none)]
545        fn netServiceBrowser_didRemoveService_moreComing(
546            &self,
547            browser: &NSNetServiceBrowser,
548            service: &NSNetService,
549            more_coming: bool,
550        );
551    }
552);