Source code

Revision control

Copy as Markdown

Other Tools

//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
extern "C" {
#[cfg(feature = "NSString")]
pub static NSNetServicesErrorCode: &'static NSString;
}
extern "C" {
#[cfg(all(feature = "NSError", feature = "NSString"))]
pub static NSNetServicesErrorDomain: &'static NSErrorDomain;
}
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSNetServicesError(pub NSInteger);
impl NSNetServicesError {
#[doc(alias = "NSNetServicesUnknownError")]
pub const UnknownError: Self = Self(-72000);
#[doc(alias = "NSNetServicesCollisionError")]
pub const CollisionError: Self = Self(-72001);
#[doc(alias = "NSNetServicesNotFoundError")]
pub const NotFoundError: Self = Self(-72002);
#[doc(alias = "NSNetServicesActivityInProgress")]
pub const ActivityInProgress: Self = Self(-72003);
#[doc(alias = "NSNetServicesBadArgumentError")]
pub const BadArgumentError: Self = Self(-72004);
#[doc(alias = "NSNetServicesCancelledError")]
pub const CancelledError: Self = Self(-72005);
#[doc(alias = "NSNetServicesInvalidError")]
pub const InvalidError: Self = Self(-72006);
#[doc(alias = "NSNetServicesTimeoutError")]
pub const TimeoutError: Self = Self(-72007);
#[doc(alias = "NSNetServicesMissingRequiredConfigurationError")]
pub const MissingRequiredConfigurationError: Self = Self(-72008);
}
unsafe impl Encode for NSNetServicesError {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSNetServicesError {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSNetServiceOptions(pub NSUInteger);
bitflags::bitflags! {
impl NSNetServiceOptions: NSUInteger {
#[doc(alias = "NSNetServiceNoAutoRename")]
const NoAutoRename = 1<<0;
#[doc(alias = "NSNetServiceListenForConnections")]
const ListenForConnections = 1<<1;
}
}
unsafe impl Encode for NSNetServiceOptions {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for NSNetServiceOptions {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
pub struct NSNetService;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSNetService {}
);
impl NSNetService {
extern_methods!(
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(initWithDomain:type:name:port:))]
#[unsafe(method_family = init)]
pub fn initWithDomain_type_name_port(
this: Allocated<Self>,
domain: &NSString,
r#type: &NSString,
name: &NSString,
port: c_int,
) -> Retained<Self>;
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(initWithDomain:type:name:))]
#[unsafe(method_family = init)]
pub fn initWithDomain_type_name(
this: Allocated<Self>,
domain: &NSString,
r#type: &NSString,
name: &NSString,
) -> Retained<Self>;
#[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
/// # Safety
///
/// `a_run_loop` possibly has additional threading requirements.
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(scheduleInRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn scheduleInRunLoop_forMode(
&self,
a_run_loop: &NSRunLoop,
mode: &NSRunLoopMode,
);
#[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
/// # Safety
///
/// `a_run_loop` possibly has additional threading requirements.
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(removeFromRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn removeFromRunLoop_forMode(
&self,
a_run_loop: &NSRunLoop,
mode: &NSRunLoopMode,
);
/// # Safety
///
/// This is not retained internally, you must ensure the object is still alive.
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(&self)
-> Option<Retained<ProtocolObject<dyn NSNetServiceDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// # Safety
///
/// This is unretained, you must ensure the object is kept alive while in use.
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSNetServiceDelegate>>,
);
#[unsafe(method(includesPeerToPeer))]
#[unsafe(method_family = none)]
pub fn includesPeerToPeer(&self) -> bool;
/// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
#[unsafe(method(setIncludesPeerToPeer:))]
#[unsafe(method_family = none)]
pub fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(name))]
#[unsafe(method_family = none)]
pub fn name(&self) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(type))]
#[unsafe(method_family = none)]
pub fn r#type(&self) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(domain))]
#[unsafe(method_family = none)]
pub fn domain(&self) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(hostName))]
#[unsafe(method_family = none)]
pub fn hostName(&self) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSData"))]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(addresses))]
#[unsafe(method_family = none)]
pub fn addresses(&self) -> Option<Retained<NSArray<NSData>>>;
#[unsafe(method(port))]
#[unsafe(method_family = none)]
pub fn port(&self) -> NSInteger;
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(publish))]
#[unsafe(method_family = none)]
pub fn publish(&self);
#[unsafe(method(publishWithOptions:))]
#[unsafe(method_family = none)]
pub fn publishWithOptions(&self, options: NSNetServiceOptions);
#[deprecated = "Not supported"]
#[unsafe(method(resolve))]
#[unsafe(method_family = none)]
pub fn resolve(&self);
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(stop))]
#[unsafe(method_family = none)]
pub fn stop(&self);
#[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(dictionaryFromTXTRecordData:))]
#[unsafe(method_family = none)]
pub fn dictionaryFromTXTRecordData(
txt_data: &NSData,
) -> Retained<NSDictionary<NSString, NSData>>;
#[cfg(all(feature = "NSData", feature = "NSDictionary", feature = "NSString"))]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(dataFromTXTRecordDictionary:))]
#[unsafe(method_family = none)]
pub fn dataFromTXTRecordDictionary(
txt_dictionary: &NSDictionary<NSString, NSData>,
) -> Retained<NSData>;
#[cfg(feature = "NSDate")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(resolveWithTimeout:))]
#[unsafe(method_family = none)]
pub fn resolveWithTimeout(&self, timeout: NSTimeInterval);
#[cfg(feature = "NSStream")]
/// # Safety
///
/// - `input_stream` must be a valid pointer or null.
/// - `output_stream` must be a valid pointer or null.
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(getInputStream:outputStream:))]
#[unsafe(method_family = none)]
pub unsafe fn getInputStream_outputStream(
&self,
input_stream: *mut *mut NSInputStream,
output_stream: *mut *mut NSOutputStream,
) -> bool;
#[cfg(feature = "NSData")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(setTXTRecordData:))]
#[unsafe(method_family = none)]
pub fn setTXTRecordData(&self, record_data: Option<&NSData>) -> bool;
#[cfg(feature = "NSData")]
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(TXTRecordData))]
#[unsafe(method_family = none)]
pub fn TXTRecordData(&self) -> Option<Retained<NSData>>;
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(startMonitoring))]
#[unsafe(method_family = none)]
pub fn startMonitoring(&self);
#[deprecated = "Use nw_connection_t or nw_listener_t in Network framework instead"]
#[unsafe(method(stopMonitoring))]
#[unsafe(method_family = none)]
pub fn stopMonitoring(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl NSNetService {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSNetService {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated = "Use nw_browser_t in Network framework instead"]
pub struct NSNetServiceBrowser;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSNetServiceBrowser {}
);
impl NSNetServiceBrowser {
extern_methods!(
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
/// # Safety
///
/// This is not retained internally, you must ensure the object is still alive.
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(delegate))]
#[unsafe(method_family = none)]
pub unsafe fn delegate(
&self,
) -> Option<Retained<ProtocolObject<dyn NSNetServiceBrowserDelegate>>>;
/// Setter for [`delegate`][Self::delegate].
///
/// # Safety
///
/// This is unretained, you must ensure the object is kept alive while in use.
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(setDelegate:))]
#[unsafe(method_family = none)]
pub unsafe fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn NSNetServiceBrowserDelegate>>,
);
#[unsafe(method(includesPeerToPeer))]
#[unsafe(method_family = none)]
pub fn includesPeerToPeer(&self) -> bool;
/// Setter for [`includesPeerToPeer`][Self::includesPeerToPeer].
#[unsafe(method(setIncludesPeerToPeer:))]
#[unsafe(method_family = none)]
pub fn setIncludesPeerToPeer(&self, includes_peer_to_peer: bool);
#[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
/// # Safety
///
/// `a_run_loop` possibly has additional threading requirements.
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(scheduleInRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn scheduleInRunLoop_forMode(
&self,
a_run_loop: &NSRunLoop,
mode: &NSRunLoopMode,
);
#[cfg(all(feature = "NSObjCRuntime", feature = "NSRunLoop", feature = "NSString"))]
/// # Safety
///
/// `a_run_loop` possibly has additional threading requirements.
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(removeFromRunLoop:forMode:))]
#[unsafe(method_family = none)]
pub unsafe fn removeFromRunLoop_forMode(
&self,
a_run_loop: &NSRunLoop,
mode: &NSRunLoopMode,
);
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(searchForBrowsableDomains))]
#[unsafe(method_family = none)]
pub fn searchForBrowsableDomains(&self);
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(searchForRegistrationDomains))]
#[unsafe(method_family = none)]
pub fn searchForRegistrationDomains(&self);
#[cfg(feature = "NSString")]
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(searchForServicesOfType:inDomain:))]
#[unsafe(method_family = none)]
pub fn searchForServicesOfType_inDomain(&self, r#type: &NSString, domain_string: &NSString);
#[deprecated = "Use nw_browser_t in Network framework instead"]
#[unsafe(method(stop))]
#[unsafe(method_family = none)]
pub fn stop(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl NSNetServiceBrowser {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSNetServiceBrowser {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
extern_protocol!(
pub unsafe trait NSNetServiceDelegate: NSObjectProtocol {
#[optional]
#[unsafe(method(netServiceWillPublish:))]
#[unsafe(method_family = none)]
fn netServiceWillPublish(&self, sender: &NSNetService);
#[optional]
#[unsafe(method(netServiceDidPublish:))]
#[unsafe(method_family = none)]
fn netServiceDidPublish(&self, sender: &NSNetService);
#[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
#[optional]
#[unsafe(method(netService:didNotPublish:))]
#[unsafe(method_family = none)]
fn netService_didNotPublish(
&self,
sender: &NSNetService,
error_dict: &NSDictionary<NSString, NSNumber>,
);
#[optional]
#[unsafe(method(netServiceWillResolve:))]
#[unsafe(method_family = none)]
fn netServiceWillResolve(&self, sender: &NSNetService);
#[optional]
#[unsafe(method(netServiceDidResolveAddress:))]
#[unsafe(method_family = none)]
fn netServiceDidResolveAddress(&self, sender: &NSNetService);
#[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
#[optional]
#[unsafe(method(netService:didNotResolve:))]
#[unsafe(method_family = none)]
fn netService_didNotResolve(
&self,
sender: &NSNetService,
error_dict: &NSDictionary<NSString, NSNumber>,
);
#[optional]
#[unsafe(method(netServiceDidStop:))]
#[unsafe(method_family = none)]
fn netServiceDidStop(&self, sender: &NSNetService);
#[cfg(feature = "NSData")]
#[optional]
#[unsafe(method(netService:didUpdateTXTRecordData:))]
#[unsafe(method_family = none)]
fn netService_didUpdateTXTRecordData(&self, sender: &NSNetService, data: &NSData);
#[cfg(feature = "NSStream")]
#[optional]
#[unsafe(method(netService:didAcceptConnectionWithInputStream:outputStream:))]
#[unsafe(method_family = none)]
fn netService_didAcceptConnectionWithInputStream_outputStream(
&self,
sender: &NSNetService,
input_stream: &NSInputStream,
output_stream: &NSOutputStream,
);
}
);
extern_protocol!(
pub unsafe trait NSNetServiceBrowserDelegate: NSObjectProtocol {
#[optional]
#[unsafe(method(netServiceBrowserWillSearch:))]
#[unsafe(method_family = none)]
fn netServiceBrowserWillSearch(&self, browser: &NSNetServiceBrowser);
#[optional]
#[unsafe(method(netServiceBrowserDidStopSearch:))]
#[unsafe(method_family = none)]
fn netServiceBrowserDidStopSearch(&self, browser: &NSNetServiceBrowser);
#[cfg(all(feature = "NSDictionary", feature = "NSString", feature = "NSValue"))]
#[optional]
#[unsafe(method(netServiceBrowser:didNotSearch:))]
#[unsafe(method_family = none)]
fn netServiceBrowser_didNotSearch(
&self,
browser: &NSNetServiceBrowser,
error_dict: &NSDictionary<NSString, NSNumber>,
);
#[cfg(feature = "NSString")]
#[optional]
#[unsafe(method(netServiceBrowser:didFindDomain:moreComing:))]
#[unsafe(method_family = none)]
fn netServiceBrowser_didFindDomain_moreComing(
&self,
browser: &NSNetServiceBrowser,
domain_string: &NSString,
more_coming: bool,
);
#[optional]
#[unsafe(method(netServiceBrowser:didFindService:moreComing:))]
#[unsafe(method_family = none)]
fn netServiceBrowser_didFindService_moreComing(
&self,
browser: &NSNetServiceBrowser,
service: &NSNetService,
more_coming: bool,
);
#[cfg(feature = "NSString")]
#[optional]
#[unsafe(method(netServiceBrowser:didRemoveDomain:moreComing:))]
#[unsafe(method_family = none)]
fn netServiceBrowser_didRemoveDomain_moreComing(
&self,
browser: &NSNetServiceBrowser,
domain_string: &NSString,
more_coming: bool,
);
#[optional]
#[unsafe(method(netServiceBrowser:didRemoveService:moreComing:))]
#[unsafe(method_family = none)]
fn netServiceBrowser_didRemoveService_moreComing(
&self,
browser: &NSNetServiceBrowser,
service: &NSNetService,
more_coming: bool,
);
}
);