objc2_accessory_setup_kit/generated/
ASAccessoryEvent.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// Type of event.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessoryeventtype?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct ASAccessoryEventType(pub NSInteger);
16impl ASAccessoryEventType {
17    /// An unknown event occurred.
18    ///
19    /// This is a placeholder value used when initializing event type instances.
20    #[doc(alias = "ASAccessoryEventTypeUnknown")]
21    pub const Unknown: Self = Self(0);
22    /// The discovery session activated.
23    #[doc(alias = "ASAccessoryEventTypeActivated")]
24    pub const Activated: Self = Self(10);
25    /// The discovery session invalidated.
26    #[doc(alias = "ASAccessoryEventTypeInvalidated")]
27    pub const Invalidated: Self = Self(11);
28    /// The migration of an accessory completed.
29    #[doc(alias = "ASAccessoryEventTypeMigrationComplete")]
30    pub const MigrationComplete: Self = Self(20);
31    /// The session added an accessory.
32    #[doc(alias = "ASAccessoryEventTypeAccessoryAdded")]
33    pub const AccessoryAdded: Self = Self(30);
34    /// The session removed an accessory.
35    #[doc(alias = "ASAccessoryEventTypeAccessoryRemoved")]
36    pub const AccessoryRemoved: Self = Self(31);
37    /// The properties of an accessory changed.
38    #[doc(alias = "ASAccessoryEventTypeAccessoryChanged")]
39    pub const AccessoryChanged: Self = Self(32);
40    /// The discovery session picker appeared.
41    #[doc(alias = "ASAccessoryEventTypePickerDidPresent")]
42    pub const PickerDidPresent: Self = Self(40);
43    /// The discovery session picker dismissed.
44    #[doc(alias = "ASAccessoryEventTypePickerDidDismiss")]
45    pub const PickerDidDismiss: Self = Self(50);
46    /// The discovery session picker started bridging with an accessory.
47    #[doc(alias = "ASAccessoryEventTypePickerSetupBridging")]
48    pub const PickerSetupBridging: Self = Self(60);
49    /// The discovery session picker setup failed.
50    #[doc(alias = "ASAccessoryEventTypePickerSetupFailed")]
51    pub const PickerSetupFailed: Self = Self(70);
52    /// The discovery session picker started pairing with a Bluetooth accessory.
53    #[doc(alias = "ASAccessoryEventTypePickerSetupPairing")]
54    pub const PickerSetupPairing: Self = Self(80);
55    /// The discovery session picker started renaming an accessory.
56    #[doc(alias = "ASAccessoryEventTypePickerSetupRename")]
57    pub const PickerSetupRename: Self = Self(90);
58}
59
60unsafe impl Encode for ASAccessoryEventType {
61    const ENCODING: Encoding = NSInteger::ENCODING;
62}
63
64unsafe impl RefEncode for ASAccessoryEventType {
65    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
66}
67
68extern_class!(
69    /// Event for status and other updates.
70    ///
71    /// See also [Apple's documentation](https://developer.apple.com/documentation/accessorysetupkit/asaccessoryevent?language=objc)
72    #[unsafe(super(NSObject))]
73    #[derive(Debug, PartialEq, Eq, Hash)]
74    pub struct ASAccessoryEvent;
75);
76
77unsafe impl Send for ASAccessoryEvent {}
78
79unsafe impl Sync for ASAccessoryEvent {}
80
81extern_conformance!(
82    unsafe impl NSObjectProtocol for ASAccessoryEvent {}
83);
84
85impl ASAccessoryEvent {
86    extern_methods!(
87        /// The type of event, such as accessory addition or removal, or picker presentation or removal.
88        ///
89        /// Some event types may indicate that the event is a subclass of ``ASAccessoryEvent-c.class`` that provides additional properties.
90        ///
91        /// This property is not atomic.
92        ///
93        /// # Safety
94        ///
95        /// This might not be thread-safe.
96        #[unsafe(method(eventType))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn eventType(&self) -> ASAccessoryEventType;
99
100        #[cfg(feature = "ASAccessory")]
101        /// The accessory involved in the event, if any.
102        ///
103        /// The session populates this member for event types like ``ASAccessoryEventType/accessoryAdded`` and ``ASAccessoryEventType/accessoryChanged``, but not for life cycle or picker events like ``ASAccessoryEventType/activated`` or ``ASAccessoryEventType/pickerDidPresent``.
104        ///
105        /// This property is not atomic.
106        ///
107        /// # Safety
108        ///
109        /// This might not be thread-safe.
110        #[unsafe(method(accessory))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn accessory(&self) -> Option<Retained<ASAccessory>>;
113
114        /// The error associated with the event, if any.
115        ///
116        /// This property is not atomic.
117        ///
118        /// # Safety
119        ///
120        /// This might not be thread-safe.
121        #[unsafe(method(error))]
122        #[unsafe(method_family = none)]
123        pub unsafe fn error(&self) -> Option<Retained<NSError>>;
124
125        #[unsafe(method(init))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
128
129        #[unsafe(method(new))]
130        #[unsafe(method_family = new)]
131        pub unsafe fn new(&self) -> Retained<Self>;
132    );
133}
134
135/// Methods declared on superclass `NSObject`.
136impl ASAccessoryEvent {
137    extern_methods!(
138        #[unsafe(method(new))]
139        #[unsafe(method_family = new)]
140        pub unsafe fn new_class() -> Retained<Self>;
141    );
142}