objc2_device_discovery_extension/generated/
DDEvent.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct DDEventType(pub NSInteger);
17impl DDEventType {
18 #[doc(alias = "DDEventTypeUnknown")]
19 pub const Unknown: Self = Self(0);
20 #[doc(alias = "DDEventTypeDeviceFound")]
22 pub const DeviceFound: Self = Self(40);
23 #[doc(alias = "DDEventTypeDeviceLost")]
25 pub const DeviceLost: Self = Self(41);
26 #[doc(alias = "DDEventTypeDeviceChanged")]
28 pub const DeviceChanged: Self = Self(42);
29}
30
31unsafe impl Encode for DDEventType {
32 const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for DDEventType {
36 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39impl DDEventType {
40 #[doc(alias = "DDEventTypeToString")]
42 #[inline]
43 pub unsafe fn to_string(self) -> Retained<NSString> {
44 extern "C-unwind" {
45 fn DDEventTypeToString(in_value: DDEventType) -> *mut NSString;
46 }
47 let ret = unsafe { DDEventTypeToString(self) };
48 unsafe { Retained::retain_autoreleased(ret) }
49 .expect("function was marked as returning non-null, but actually returned NULL")
50 }
51}
52
53#[cfg(feature = "block2")]
57pub type DDEventHandler = *mut block2::DynBlock<dyn Fn(NonNull<DDDeviceEvent>)>;
58
59extern_class!(
60 #[unsafe(super(NSObject))]
64 #[derive(Debug, PartialEq, Eq, Hash)]
65 pub struct DDDeviceEvent;
66);
67
68extern_conformance!(
69 unsafe impl NSObjectProtocol for DDDeviceEvent {}
70);
71
72impl DDDeviceEvent {
73 extern_methods!(
74 #[cfg(feature = "DDDevice")]
75 #[unsafe(method(initWithEventType:device:))]
77 #[unsafe(method_family = init)]
78 pub unsafe fn initWithEventType_device(
79 this: Allocated<Self>,
80 r#type: DDEventType,
81 device: &DDDevice,
82 ) -> Retained<Self>;
83
84 #[cfg(feature = "DDDevice")]
85 #[unsafe(method(device))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn device(&self) -> Retained<DDDevice>;
89
90 #[unsafe(method(eventType))]
92 #[unsafe(method_family = none)]
93 pub unsafe fn eventType(&self) -> DDEventType;
94 );
95}
96
97impl DDDeviceEvent {
99 extern_methods!(
100 #[unsafe(method(init))]
101 #[unsafe(method_family = init)]
102 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
103
104 #[unsafe(method(new))]
105 #[unsafe(method_family = new)]
106 pub unsafe fn new() -> Retained<Self>;
107 );
108}
109
110#[deprecated = "renamed to `DDEventType::to_string`"]
111#[inline]
112pub unsafe extern "C-unwind" fn DDEventTypeToString(in_value: DDEventType) -> Retained<NSString> {
113 extern "C-unwind" {
114 fn DDEventTypeToString(in_value: DDEventType) -> *mut NSString;
115 }
116 let ret = unsafe { DDEventTypeToString(in_value) };
117 unsafe { Retained::retain_autoreleased(ret) }
118 .expect("function was marked as returning non-null, but actually returned NULL")
119}