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/mcnearbyserviceadvertiser?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MCNearbyServiceAdvertiser;
);

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

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

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

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

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

        /// 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 MCNearbyServiceAdvertiserDelegate>>,
        );

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

        #[unsafe(method(discoveryInfo))]
        #[unsafe(method_family = none)]
        pub unsafe fn discoveryInfo(&self) -> Option<Retained<NSDictionary<NSString, NSString>>>;

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

/// Methods declared on superclass `NSObject`.
impl MCNearbyServiceAdvertiser {
    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/mcnearbyserviceadvertiserdelegate?language=objc)
    pub unsafe trait MCNearbyServiceAdvertiserDelegate: NSObjectProtocol {
        #[cfg(all(feature = "MCPeerID", feature = "MCSession", feature = "block2"))]
        #[unsafe(method(advertiser:didReceiveInvitationFromPeer:withContext:invitationHandler:))]
        #[unsafe(method_family = none)]
        unsafe fn advertiser_didReceiveInvitationFromPeer_withContext_invitationHandler(
            &self,
            advertiser: &MCNearbyServiceAdvertiser,
            peer_id: &MCPeerID,
            context: Option<&NSData>,
            invitation_handler: &block2::DynBlock<dyn Fn(Bool, *mut MCSession)>,
        );

        #[optional]
        #[unsafe(method(advertiser:didNotStartAdvertisingPeer:))]
        #[unsafe(method_family = none)]
        unsafe fn advertiser_didNotStartAdvertisingPeer(
            &self,
            advertiser: &MCNearbyServiceAdvertiser,
            error: &NSError,
        );
    }
);