objc2-multipeer-connectivity 0.3.2

Bindings to the MultipeerConnectivity framework
Documentation
//! 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 objc2_foundation::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/multipeerconnectivity/mcnearbyservicebrowser?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MCNearbyServiceBrowser;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for MCNearbyServiceBrowser {}
);

impl MCNearbyServiceBrowser {
    extern_methods!(
        #[cfg(feature = "MCPeerID")]
        #[unsafe(method(initWithPeer:serviceType:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithPeer_serviceType(
            this: Allocated<Self>,
            my_peer_id: &MCPeerID,
            service_type: &NSString,
        ) -> Retained<Self>;

        #[unsafe(method(startBrowsingForPeers))]
        #[unsafe(method_family = none)]
        pub unsafe fn startBrowsingForPeers(&self);

        #[unsafe(method(stopBrowsingForPeers))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopBrowsingForPeers(&self);

        #[cfg(all(feature = "MCPeerID", feature = "MCSession"))]
        #[unsafe(method(invitePeer:toSession:withContext:timeout:))]
        #[unsafe(method_family = none)]
        pub unsafe fn invitePeer_toSession_withContext_timeout(
            &self,
            peer_id: &MCPeerID,
            session: &MCSession,
            context: Option<&NSData>,
            timeout: NSTimeInterval,
        );

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn MCNearbyServiceBrowserDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn MCNearbyServiceBrowserDelegate>>,
        );

        #[cfg(feature = "MCPeerID")]
        #[unsafe(method(myPeerID))]
        #[unsafe(method_family = none)]
        pub unsafe fn myPeerID(&self) -> Retained<MCPeerID>;

        #[unsafe(method(serviceType))]
        #[unsafe(method_family = none)]
        pub unsafe fn serviceType(&self) -> Retained<NSString>;
    );
}

/// Methods declared on superclass `NSObject`.
impl MCNearbyServiceBrowser {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/multipeerconnectivity/mcnearbyservicebrowserdelegate?language=objc)
    pub unsafe trait MCNearbyServiceBrowserDelegate: NSObjectProtocol {
        #[cfg(feature = "MCPeerID")]
        #[unsafe(method(browser:foundPeer:withDiscoveryInfo:))]
        #[unsafe(method_family = none)]
        unsafe fn browser_foundPeer_withDiscoveryInfo(
            &self,
            browser: &MCNearbyServiceBrowser,
            peer_id: &MCPeerID,
            info: Option<&NSDictionary<NSString, NSString>>,
        );

        #[cfg(feature = "MCPeerID")]
        #[unsafe(method(browser:lostPeer:))]
        #[unsafe(method_family = none)]
        unsafe fn browser_lostPeer(&self, browser: &MCNearbyServiceBrowser, peer_id: &MCPeerID);

        #[optional]
        #[unsafe(method(browser:didNotStartBrowsingForPeers:))]
        #[unsafe(method_family = none)]
        unsafe fn browser_didNotStartBrowsingForPeers(
            &self,
            browser: &MCNearbyServiceBrowser,
            error: &NSError,
        );
    }
);