objc2-core-bluetooth 0.3.2

Bindings to the CoreBluetooth framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

/// Represents the current state of a CBPeripheralManager.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerauthorizationstatus?language=objc)
// NS_ENUM
#[deprecated = "Use CBManagerAuthorization instead"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBPeripheralManagerAuthorizationStatus(pub NSInteger);
impl CBPeripheralManagerAuthorizationStatus {
    #[doc(alias = "CBPeripheralManagerAuthorizationStatusNotDetermined")]
    #[deprecated = "Use CBManagerAuthorization instead"]
    pub const NotDetermined: Self = Self(0);
    #[doc(alias = "CBPeripheralManagerAuthorizationStatusRestricted")]
    #[deprecated = "Use CBManagerAuthorization instead"]
    pub const Restricted: Self = Self(1);
    #[doc(alias = "CBPeripheralManagerAuthorizationStatusDenied")]
    #[deprecated = "Use CBManagerAuthorization instead"]
    pub const Denied: Self = Self(2);
    #[doc(alias = "CBPeripheralManagerAuthorizationStatusAuthorized")]
    #[deprecated = "Use CBManagerAuthorization instead"]
    pub const Authorized: Self = Self(3);
}

unsafe impl Encode for CBPeripheralManagerAuthorizationStatus {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CBPeripheralManagerAuthorizationStatus {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Represents the current state of a CBPeripheralManager.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerstate?language=objc)
// NS_ENUM
#[deprecated = "Use CBManagerState instead"]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBPeripheralManagerState(pub NSInteger);
impl CBPeripheralManagerState {
    #[doc(alias = "CBPeripheralManagerStateUnknown")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const Unknown: Self = Self(CBManagerState::Unknown.0);
    #[doc(alias = "CBPeripheralManagerStateResetting")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const Resetting: Self = Self(CBManagerState::Resetting.0);
    #[doc(alias = "CBPeripheralManagerStateUnsupported")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const Unsupported: Self = Self(CBManagerState::Unsupported.0);
    #[doc(alias = "CBPeripheralManagerStateUnauthorized")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const Unauthorized: Self = Self(CBManagerState::Unauthorized.0);
    #[doc(alias = "CBPeripheralManagerStatePoweredOff")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const PoweredOff: Self = Self(CBManagerState::PoweredOff.0);
    #[doc(alias = "CBPeripheralManagerStatePoweredOn")]
    #[cfg(feature = "CBManager")]
    #[deprecated = "Use CBManagerState instead"]
    pub const PoweredOn: Self = Self(CBManagerState::PoweredOn.0);
}

unsafe impl Encode for CBPeripheralManagerState {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CBPeripheralManagerState {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// The latency of a peripheral-central connection controls how frequently messages can be exchanged.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerconnectionlatency?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CBPeripheralManagerConnectionLatency(pub NSInteger);
impl CBPeripheralManagerConnectionLatency {
    #[doc(alias = "CBPeripheralManagerConnectionLatencyLow")]
    pub const Low: Self = Self(0);
    #[doc(alias = "CBPeripheralManagerConnectionLatencyMedium")]
    pub const Medium: Self = Self(1);
    #[doc(alias = "CBPeripheralManagerConnectionLatencyHigh")]
    pub const High: Self = Self(2);
}

unsafe impl Encode for CBPeripheralManagerConnectionLatency {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CBPeripheralManagerConnectionLatency {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// The
    /// <code>
    /// CBPeripheralManager
    /// </code>
    /// class is an abstraction of the Peripheral and Broadcaster GAP roles, and the GATT Server
    /// role. Its primary function is to allow you to manage published services within the GATT database, and to advertise these services
    /// to other devices.
    /// Each application has sandboxed access to the shared GATT database. You can add services to the database by calling {
    ///
    /// ```text
    ///  addService:};
    ///               they can be removed via {@link removeService:} and {@link removeAllServices}, as appropriate. While a service is in the database,
    ///               it is visible to and can be accessed by any connected GATT Client. However, applications that have not specified the "bluetooth-peripheral"
    ///               background mode will have the contents of their service(s) "disabled" when in the background. Any remote device trying to access
    ///               characteristic values or descriptors during this time will receive an error response.
    ///               Once you've published services that you want to share, you can ask to advertise their availability and allow other devices to connect
    ///               to you by calling {@link startAdvertising:}. Like the GATT database, advertisement is managed at the system level and shared by all
    ///               applications. This means that even if you aren't advertising at the moment, someone else might be!
    ///
    ///  
    ///
    /// ```
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager?language=objc)
    #[unsafe(super(CBManager, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "CBManager")]
    pub struct CBPeripheralManager;
);

#[cfg(feature = "CBManager")]
extern_conformance!(
    unsafe impl NSObjectProtocol for CBPeripheralManager {}
);

#[cfg(feature = "CBManager")]
impl CBPeripheralManager {
    extern_methods!(
        /// The delegate object that will receive peripheral events.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn CBPeripheralManagerDelegate>>>;

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

        /// Whether or not the peripheral is currently advertising data.
        #[unsafe(method(isAdvertising))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAdvertising(&self) -> bool;

        /// This method does not prompt the user for access. You can use it to detect restricted access and simply hide UI instead of
        /// prompting for access.
        ///
        ///
        /// Returns: The current authorization status for sharing data while backgrounded. For the constants returned, see {
        ///
        /// ```text
        ///  CBPeripheralManagerAuthorizationStatus}.
        ///
        ///   @see        CBPeripheralManagerAuthorizationStatus
        ///  
        ///
        /// ```
        #[deprecated = "Use CBManagerAuthorization instead"]
        #[unsafe(method(authorizationStatus))]
        #[unsafe(method_family = none)]
        pub unsafe fn authorizationStatus() -> CBPeripheralManagerAuthorizationStatus;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `delegate`: The delegate that will receive peripheral role events.
        ///
        /// Parameter `queue`: The dispatch queue on which the events will be dispatched.
        ///
        ///
        /// The initialization call. The events of the peripheral role will be dispatched on the provided queue.
        /// If
        /// <i>
        /// nil
        /// </i>
        /// , the main queue will be used.
        ///
        /// # Safety
        ///
        /// `queue` possibly has additional threading requirements.
        #[unsafe(method(initWithDelegate:queue:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate_queue(
            this: Allocated<Self>,
            delegate: Option<&ProtocolObject<dyn CBPeripheralManagerDelegate>>,
            queue: Option<&DispatchQueue>,
        ) -> Retained<Self>;

        #[cfg(feature = "dispatch2")]
        /// Parameter `delegate`: The delegate that will receive peripheral role events.
        ///
        /// Parameter `queue`: The dispatch queue on which the events will be dispatched.
        ///
        /// Parameter `options`: An optional dictionary specifying options for the manager.
        ///
        ///
        /// The initialization call. The events of the peripheral role will be dispatched on the provided queue.
        /// If
        /// <i>
        /// nil
        /// </i>
        /// , the main queue will be used.
        ///
        ///
        /// See also: CBPeripheralManagerOptionShowPowerAlertKey
        ///
        /// See also: CBPeripheralManagerOptionRestoreIdentifierKey
        ///
        /// # Safety
        ///
        /// - `queue` possibly has additional threading requirements.
        /// - `options` generic should be of the correct type.
        #[unsafe(method(initWithDelegate:queue:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDelegate_queue_options(
            this: Allocated<Self>,
            delegate: Option<&ProtocolObject<dyn CBPeripheralManagerDelegate>>,
            queue: Option<&DispatchQueue>,
            options: Option<&NSDictionary<NSString, AnyObject>>,
        ) -> Retained<Self>;

        /// Parameter `advertisementData`: An optional dictionary containing the data to be advertised.
        ///
        ///
        /// Starts advertising. Supported advertising data types are
        /// <code>
        /// CBAdvertisementDataLocalNameKey
        /// </code>
        /// and
        /// <code>
        /// CBAdvertisementDataServiceUUIDsKey
        /// </code>
        /// .
        /// When in the foreground, an application can utilize up to 28 bytes of space in the initial advertisement data for
        /// any combination of the supported advertising data types. If this space is used up, there are an additional 10 bytes of
        /// space in the scan response that can be used only for the local name. Note that these sizes do not include the 2 bytes
        /// of header information that are required for each new data type. Any service UUIDs that do not fit in the allotted space
        /// will be added to a special "overflow" area, and can only be discovered by an iOS device that is explicitly scanning
        /// for them.
        /// While an application is in the background, the local name will not be used and all service UUIDs will be placed in the
        /// "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able
        /// to advertise anything while in the background.
        ///
        ///
        /// See: peripheralManagerDidStartAdvertising:error:
        ///
        /// See also: CBAdvertisementData.h
        ///
        /// # Safety
        ///
        /// `advertisement_data` generic should be of the correct type.
        #[unsafe(method(startAdvertising:))]
        #[unsafe(method_family = none)]
        pub unsafe fn startAdvertising(
            &self,
            advertisement_data: Option<&NSDictionary<NSString, AnyObject>>,
        );

        /// Stops advertising.
        #[unsafe(method(stopAdvertising))]
        #[unsafe(method_family = none)]
        pub unsafe fn stopAdvertising(&self);

        #[cfg(all(feature = "CBCentral", feature = "CBPeer"))]
        /// Parameter `latency`: The desired connection latency.
        ///
        /// Parameter `central`: A connected central.
        ///
        ///
        /// Sets the desired connection latency for an existing connection to
        /// <i>
        /// central
        /// </i>
        /// . Connection latency changes are not guaranteed, so the
        /// resultant latency may vary. If a desired latency is not set, the latency chosen by
        /// <i>
        /// central
        /// </i>
        /// at the time of connection establishment
        /// will be used. Typically, it is not necessary to change the latency.
        ///
        ///
        /// See: CBPeripheralManagerConnectionLatency
        #[unsafe(method(setDesiredConnectionLatency:forCentral:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDesiredConnectionLatency_forCentral(
            &self,
            latency: CBPeripheralManagerConnectionLatency,
            central: &CBCentral,
        );

        #[cfg(all(feature = "CBAttribute", feature = "CBService"))]
        /// Parameter `service`: A GATT service.
        ///
        ///
        /// Publishes a service and its associated characteristic(s) to the local database. If the service contains included services,
        /// they must be published first.
        ///
        ///
        /// See: peripheralManager:didAddService:error:
        #[unsafe(method(addService:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addService(&self, service: &CBMutableService);

        #[cfg(all(feature = "CBAttribute", feature = "CBService"))]
        /// Parameter `service`: A GATT service.
        ///
        ///
        /// Removes a published service from the local database. If the service is included by other service(s), they must be removed
        /// first.
        #[unsafe(method(removeService:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeService(&self, service: &CBMutableService);

        /// Removes all published services from the local database.
        #[unsafe(method(removeAllServices))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAllServices(&self);

        #[cfg(all(feature = "CBATTRequest", feature = "CBError"))]
        /// Parameter `request`: The original request that was received from the central.
        ///
        /// Parameter `result`: The result of attempting to fulfill
        /// <i>
        /// request
        /// </i>
        /// .
        ///
        ///
        /// Used to respond to request(s) received via the
        ///
        /// ```text
        ///  peripheralManager:didReceiveReadRequest:
        /// ```
        ///
        /// or
        ///
        /// ```text
        ///  peripheralManager:didReceiveWriteRequests:
        /// ```
        ///
        /// delegate methods.
        ///
        ///
        /// See: peripheralManager:didReceiveReadRequest:
        ///
        /// See: peripheralManager:didReceiveWriteRequests:
        #[unsafe(method(respondToRequest:withResult:))]
        #[unsafe(method_family = none)]
        pub unsafe fn respondToRequest_withResult(
            &self,
            request: &CBATTRequest,
            result: CBATTError,
        );

        #[cfg(all(
            feature = "CBAttribute",
            feature = "CBCentral",
            feature = "CBCharacteristic",
            feature = "CBPeer"
        ))]
        /// Parameter `value`: The value to be sent via a notification/indication.
        ///
        /// Parameter `characteristic`: The characteristic whose value has changed.
        ///
        /// Parameter `centrals`: A list of
        /// <code>
        /// CBCentral
        /// </code>
        /// objects to receive the update. Note that centrals which have not subscribed to
        /// <i>
        /// characteristic
        /// </i>
        /// will be ignored. If
        /// <i>
        /// nil
        /// </i>
        /// , all centrals that are subscribed to
        /// <i>
        /// characteristic
        /// </i>
        /// will be updated.
        ///
        ///
        /// Sends an updated characteristic value to one or more centrals, via a notification or indication. If
        /// <i>
        /// value
        /// </i>
        /// exceeds
        /// {
        ///
        /// ```text
        ///  maximumUpdateValueLength}, it will be truncated to fit.
        ///
        ///   @return                 <i>YES</i> if the update could be sent, or <i>NO</i> if the underlying transmit queue is full. If <i>NO</i> was returned,
        ///                           the delegate method @link peripheralManagerIsReadyToUpdateSubscribers:
        /// ```
        ///
        /// will be called once space has become
        /// available, and the update should be re-sent if so desired.
        ///
        ///
        /// See: peripheralManager:central:didSubscribeToCharacteristic:
        ///
        /// See: peripheralManager:central:didUnsubscribeFromCharacteristic:
        ///
        /// See: peripheralManagerIsReadyToUpdateSubscribers:
        ///
        /// See also: maximumUpdateValueLength
        #[unsafe(method(updateValue:forCharacteristic:onSubscribedCentrals:))]
        #[unsafe(method_family = none)]
        pub unsafe fn updateValue_forCharacteristic_onSubscribedCentrals(
            &self,
            value: &NSData,
            characteristic: &CBMutableCharacteristic,
            centrals: Option<&NSArray<CBCentral>>,
        ) -> bool;

        /// Parameter `encryptionRequired`: YES if the service requires the link to be encrypted before a stream can be established.  NO if the service can be used over
        /// an unsecured link.
        ///
        ///
        /// Create a listener for incoming L2CAP Channel connections.  The system will determine an unused PSM at the time of publishing, which will be returned
        /// with
        ///
        /// ```text
        ///  peripheralManager:didPublishL2CAPChannel:error:
        /// ```
        ///
        /// .  L2CAP Channels are not discoverable by themselves, so it is the application's
        /// responsibility to handle PSM discovery on the client.
        #[unsafe(method(publishL2CAPChannelWithEncryption:))]
        #[unsafe(method_family = none)]
        pub unsafe fn publishL2CAPChannelWithEncryption(&self, encryption_required: bool);

        #[cfg(feature = "CBL2CAPChannel")]
        /// Parameter `PSM`: The service PSM to be removed from the system.
        ///
        ///
        /// Removes a published service from the local system.  No new connections for this PSM will be accepted, and any existing L2CAP channels
        /// using this PSM will be closed.
        #[unsafe(method(unpublishL2CAPChannel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn unpublishL2CAPChannel(&self, psm: CBL2CAPPSM);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "CBManager")]
impl CBPeripheralManager {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_protocol!(
    /// The delegate of a
    ///
    /// ```text
    ///  CBPeripheralManager
    /// ```
    ///
    /// object must adopt the
    /// <code>
    /// CBPeripheralManagerDelegate
    /// </code>
    /// protocol. The
    /// single required method indicates the availability of the peripheral manager, while the optional methods provide information about
    /// centrals, which can connect and access the local database.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/corebluetooth/cbperipheralmanagerdelegate?language=objc)
    pub unsafe trait CBPeripheralManagerDelegate: NSObjectProtocol {
        #[cfg(feature = "CBManager")]
        /// Parameter `peripheral`: The peripheral manager whose state has changed.
        ///
        ///
        /// Invoked whenever the peripheral manager's state has been updated. Commands should only be issued when the state is
        /// <code>
        /// CBPeripheralManagerStatePoweredOn
        /// </code>
        /// . A state below
        /// <code>
        /// CBPeripheralManagerStatePoweredOn
        /// </code>
        /// implies that advertisement has paused and any connected centrals have been disconnected. If the state moves below
        /// <code>
        /// CBPeripheralManagerStatePoweredOff
        /// </code>
        /// , advertisement is stopped and must be explicitly restarted, and the
        /// local database is cleared and all services must be re-added.
        ///
        ///
        /// See: state
        #[unsafe(method(peripheralManagerDidUpdateState:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManagerDidUpdateState(&self, peripheral: &CBPeripheralManager);

        #[cfg(feature = "CBManager")]
        /// Parameter `peripheral`: The peripheral manager providing this information.
        ///
        /// Parameter `dict`: A dictionary containing information about
        /// <i>
        /// peripheral
        /// </i>
        /// that was preserved by the system at the time the app was terminated.
        ///
        ///
        /// For apps that opt-in to state preservation and restoration, this is the first method invoked when your app is relaunched into
        /// the background to complete some Bluetooth-related task. Use this method to synchronize your app's state with the state of the
        /// Bluetooth system.
        ///
        ///
        /// See also: CBPeripheralManagerRestoredStateServicesKey;
        ///
        /// See also: CBPeripheralManagerRestoredStateAdvertisementDataKey;
        ///
        /// # Safety
        ///
        /// `dict` generic should be of the correct type.
        #[optional]
        #[unsafe(method(peripheralManager:willRestoreState:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_willRestoreState(
            &self,
            peripheral: &CBPeripheralManager,
            dict: &NSDictionary<NSString, AnyObject>,
        );

        #[cfg(feature = "CBManager")]
        /// Parameter `peripheral`: The peripheral manager providing this information.
        ///
        /// Parameter `error`: If an error occurred, the cause of the failure.
        ///
        ///
        /// This method returns the result of a
        ///
        /// ```text
        ///  startAdvertising:
        /// ```
        ///
        /// call. If advertisement could
        /// not be started, the cause will be detailed in the
        /// <i>
        /// error
        /// </i>
        /// parameter.
        #[optional]
        #[unsafe(method(peripheralManagerDidStartAdvertising:error:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManagerDidStartAdvertising_error(
            &self,
            peripheral: &CBPeripheralManager,
            error: Option<&NSError>,
        );

        #[cfg(all(feature = "CBAttribute", feature = "CBManager", feature = "CBService"))]
        /// Parameter `peripheral`: The peripheral manager providing this information.
        ///
        /// Parameter `service`: The service that was added to the local database.
        ///
        /// Parameter `error`: If an error occurred, the cause of the failure.
        ///
        ///
        /// This method returns the result of an
        ///
        /// ```text
        ///  addService:
        /// ```
        ///
        /// call. If the service could
        /// not be published to the local database, the cause will be detailed in the
        /// <i>
        /// error
        /// </i>
        /// parameter.
        #[optional]
        #[unsafe(method(peripheralManager:didAddService:error:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didAddService_error(
            &self,
            peripheral: &CBPeripheralManager,
            service: &CBService,
            error: Option<&NSError>,
        );

        #[cfg(all(
            feature = "CBAttribute",
            feature = "CBCentral",
            feature = "CBCharacteristic",
            feature = "CBManager",
            feature = "CBPeer"
        ))]
        /// Parameter `peripheral`: The peripheral manager providing this update.
        ///
        /// Parameter `central`: The central that issued the command.
        ///
        /// Parameter `characteristic`: The characteristic on which notifications or indications were enabled.
        ///
        ///
        /// This method is invoked when a central configures
        /// <i>
        /// characteristic
        /// </i>
        /// to notify or indicate.
        /// It should be used as a cue to start sending updates as the characteristic value changes.
        #[optional]
        #[unsafe(method(peripheralManager:central:didSubscribeToCharacteristic:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_central_didSubscribeToCharacteristic(
            &self,
            peripheral: &CBPeripheralManager,
            central: &CBCentral,
            characteristic: &CBCharacteristic,
        );

        #[cfg(all(
            feature = "CBAttribute",
            feature = "CBCentral",
            feature = "CBCharacteristic",
            feature = "CBManager",
            feature = "CBPeer"
        ))]
        /// Parameter `peripheral`: The peripheral manager providing this update.
        ///
        /// Parameter `central`: The central that issued the command.
        ///
        /// Parameter `characteristic`: The characteristic on which notifications or indications were disabled.
        ///
        ///
        /// This method is invoked when a central removes notifications/indications from
        /// <i>
        /// characteristic
        /// </i>
        /// .
        #[optional]
        #[unsafe(method(peripheralManager:central:didUnsubscribeFromCharacteristic:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_central_didUnsubscribeFromCharacteristic(
            &self,
            peripheral: &CBPeripheralManager,
            central: &CBCentral,
            characteristic: &CBCharacteristic,
        );

        #[cfg(all(feature = "CBATTRequest", feature = "CBManager"))]
        /// Parameter `peripheral`: The peripheral manager requesting this information.
        ///
        /// Parameter `request`: A
        /// <code>
        /// CBATTRequest
        /// </code>
        /// object.
        ///
        ///
        /// This method is invoked when
        /// <i>
        /// peripheral
        /// </i>
        /// receives an ATT request for a characteristic with a dynamic value.
        /// For every invocation of this method,
        ///
        /// ```text
        ///  respondToRequest:withResult:
        /// ```
        ///
        /// must be called.
        ///
        ///
        /// See: CBATTRequest
        #[optional]
        #[unsafe(method(peripheralManager:didReceiveReadRequest:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didReceiveReadRequest(
            &self,
            peripheral: &CBPeripheralManager,
            request: &CBATTRequest,
        );

        #[cfg(all(feature = "CBATTRequest", feature = "CBManager"))]
        /// Parameter `peripheral`: The peripheral manager requesting this information.
        ///
        /// Parameter `requests`: A list of one or more
        /// <code>
        /// CBATTRequest
        /// </code>
        /// objects.
        ///
        ///
        /// This method is invoked when
        /// <i>
        /// peripheral
        /// </i>
        /// receives an ATT request or command for one or more characteristics with a dynamic value.
        /// For every invocation of this method,
        ///
        /// ```text
        ///  respondToRequest:withResult:
        /// ```
        ///
        /// should be called exactly once. If
        /// <i>
        /// requests
        /// </i>
        /// contains
        /// multiple requests, they must be treated as an atomic unit. If the execution of one of the requests would cause a failure, the request
        /// and error reason should be provided to
        /// <code>
        /// respondToRequest:withResult:
        /// </code>
        /// and none of the requests should be executed.
        ///
        ///
        /// See: CBATTRequest
        #[optional]
        #[unsafe(method(peripheralManager:didReceiveWriteRequests:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didReceiveWriteRequests(
            &self,
            peripheral: &CBPeripheralManager,
            requests: &NSArray<CBATTRequest>,
        );

        #[cfg(feature = "CBManager")]
        /// Parameter `peripheral`: The peripheral manager providing this update.
        ///
        ///
        /// This method is invoked after a failed call to
        ///
        /// ```text
        ///  updateValue:forCharacteristic:onSubscribedCentrals:
        /// ```
        ///
        /// , when
        /// <i>
        /// peripheral
        /// </i>
        /// is again
        /// ready to send characteristic value updates.
        #[optional]
        #[unsafe(method(peripheralManagerIsReadyToUpdateSubscribers:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManagerIsReadyToUpdateSubscribers(
            &self,
            peripheral: &CBPeripheralManager,
        );

        #[cfg(all(feature = "CBL2CAPChannel", feature = "CBManager"))]
        /// Parameter `peripheral`: The peripheral manager requesting this information.
        ///
        /// Parameter `PSM`: The PSM of the channel that was published.
        ///
        /// Parameter `error`: If an error occurred, the cause of the failure.
        ///
        ///
        /// This method is the response to a
        ///
        /// ```text
        ///  publishL2CAPChannel:
        /// ```
        ///
        /// call.  The PSM will contain the PSM that was assigned for the published
        /// channel
        #[optional]
        #[unsafe(method(peripheralManager:didPublishL2CAPChannel:error:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didPublishL2CAPChannel_error(
            &self,
            peripheral: &CBPeripheralManager,
            psm: CBL2CAPPSM,
            error: Option<&NSError>,
        );

        #[cfg(all(feature = "CBL2CAPChannel", feature = "CBManager"))]
        /// Parameter `peripheral`: The peripheral manager requesting this information.
        ///
        /// Parameter `PSM`: The PSM of the channel that was published.
        ///
        /// Parameter `error`: If an error occurred, the cause of the failure.
        ///
        ///
        /// This method is the response to a
        ///
        /// ```text
        ///  unpublishL2CAPChannel:
        /// ```
        ///
        /// call.
        #[optional]
        #[unsafe(method(peripheralManager:didUnpublishL2CAPChannel:error:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didUnpublishL2CAPChannel_error(
            &self,
            peripheral: &CBPeripheralManager,
            psm: CBL2CAPPSM,
            error: Option<&NSError>,
        );

        #[cfg(all(feature = "CBL2CAPChannel", feature = "CBManager"))]
        /// Parameter `peripheral`: The peripheral manager requesting this information.
        ///
        /// Parameter `channel`: A
        /// <code>
        /// CBL2CAPChannel
        /// </code>
        /// object.
        ///
        /// Parameter `error`: If an error occurred, the cause of the failure.
        ///
        ///
        /// This method returns the result of establishing an incoming L2CAP channel , following publishing a channel using
        ///
        /// ```text
        ///  publishL2CAPChannel: @link call.
        ///
        ///  
        ///
        /// ```
        #[optional]
        #[unsafe(method(peripheralManager:didOpenL2CAPChannel:error:))]
        #[unsafe(method_family = none)]
        unsafe fn peripheralManager_didOpenL2CAPChannel_error(
            &self,
            peripheral: &CBPeripheralManager,
            channel: Option<&CBL2CAPChannel>,
            error: Option<&NSError>,
        );
    }
);