objc2_av_routing/generated/AVCustomRoutingController.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern "C" {
11 /// A notification the system posts when the list of authorized routes changes.
12 ///
13 /// See also [Apple's documentation](https://developer.apple.com/documentation/avrouting/avcustomroutingcontrollerauthorizedroutesdidchangenotification?language=objc)
14 pub static AVCustomRoutingControllerAuthorizedRoutesDidChangeNotification:
15 &'static NSNotificationName;
16}
17
18extern_class!(
19 /// An object that manages the connection from a device to a destination.
20 ///
21 /// A routing controller also informs its ``AVCustomRoutingController/delegate``
22 /// object about which routes the user previously authorized, so it can
23 /// reconnect, if appropriate.
24 ///
25 /// See also [Apple's documentation](https://developer.apple.com/documentation/avrouting/avcustomroutingcontroller?language=objc)
26 #[unsafe(super(NSObject))]
27 #[derive(Debug, PartialEq, Eq, Hash)]
28 pub struct AVCustomRoutingController;
29);
30
31extern_conformance!(
32 unsafe impl NSObjectProtocol for AVCustomRoutingController {}
33);
34
35impl AVCustomRoutingController {
36 extern_methods!(
37 /// A delegate object for a routing controller.
38 #[unsafe(method(delegate))]
39 #[unsafe(method_family = none)]
40 pub unsafe fn delegate(
41 &self,
42 ) -> Option<Retained<ProtocolObject<dyn AVCustomRoutingControllerDelegate>>>;
43
44 /// Setter for [`delegate`][Self::delegate].
45 ///
46 /// This is a [weak property][objc2::topics::weak_property].
47 #[unsafe(method(setDelegate:))]
48 #[unsafe(method_family = none)]
49 pub unsafe fn setDelegate(
50 &self,
51 delegate: Option<&ProtocolObject<dyn AVCustomRoutingControllerDelegate>>,
52 );
53
54 #[cfg(feature = "AVCustomDeviceRoute")]
55 /// A list of authorized routes.
56 ///
57 /// After a user activates a route, it remains authorized for a certain amount
58 /// of time even if the connection to the route is temporarily unavailable. Your
59 /// app may reactivate any one of these routes when appropriate, but it needs to
60 /// inform the system by calling
61 /// ``AVCustomRoutingController/setActive:forRoute:``.
62 #[unsafe(method(authorizedRoutes))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn authorizedRoutes(&self) -> Retained<NSArray<AVCustomDeviceRoute>>;
65
66 /// An array of route addresses known to be on the local network.
67 #[unsafe(method(knownRouteIPs))]
68 #[unsafe(method_family = none)]
69 pub unsafe fn knownRouteIPs(&self) -> Retained<NSArray<AVCustomRoutingPartialIP>>;
70
71 /// Setter for [`knownRouteIPs`][Self::knownRouteIPs].
72 #[unsafe(method(setKnownRouteIPs:))]
73 #[unsafe(method_family = none)]
74 pub unsafe fn setKnownRouteIPs(&self, known_route_i_ps: &NSArray<AVCustomRoutingPartialIP>);
75
76 #[cfg(feature = "AVCustomRoutingActionItem")]
77 /// An array of custom action items to add to a route picker.
78 #[unsafe(method(customActionItems))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn customActionItems(&self) -> Retained<NSArray<AVCustomRoutingActionItem>>;
81
82 #[cfg(feature = "AVCustomRoutingActionItem")]
83 /// Setter for [`customActionItems`][Self::customActionItems].
84 #[unsafe(method(setCustomActionItems:))]
85 #[unsafe(method_family = none)]
86 pub unsafe fn setCustomActionItems(
87 &self,
88 custom_action_items: &NSArray<AVCustomRoutingActionItem>,
89 );
90
91 #[cfg(feature = "AVCustomDeviceRoute")]
92 /// Revokes an app’s authorization to connect to a route.
93 ///
94 /// The route only becomes authorized again if the user selects it using the
95 /// route picker.
96 ///
97 /// - Parameters:
98 /// - route: The route to invalidate authorization for.
99 #[unsafe(method(invalidateAuthorizationForRoute:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn invalidateAuthorizationForRoute(&self, route: &AVCustomDeviceRoute);
102
103 #[cfg(feature = "AVCustomDeviceRoute")]
104 /// Sets the active state of a route.
105 ///
106 /// Set the value to
107 /// <doc
108 /// ://com.apple.documentation/documentation/objectivec/no>
109 /// if the connection to the route becomes unavailable, and set it to
110 /// <doc
111 /// ://com.apple.documentation/documentation/objectivec/yes> after you
112 /// reestablish the connection.
113 ///
114 /// - Parameters:
115 /// - active: A Boolean value that indicates whether the route is active.
116 ///
117 /// - route: A route to change the active state for.
118 #[unsafe(method(setActive:forRoute:))]
119 #[unsafe(method_family = none)]
120 pub unsafe fn setActive_forRoute(&self, active: bool, route: &AVCustomDeviceRoute);
121
122 #[cfg(feature = "AVCustomDeviceRoute")]
123 /// Returns a Boolean value that indicates whether a route is active.
124 ///
125 /// - Parameters:
126 /// - route: A route for determining its active state.
127 ///
128 /// - Returns:
129 /// <doc
130 /// ://com.apple.documentation/documentation/objectivec/yes> if
131 /// the route is in an active state; otherwise,
132 /// <doc
133 /// ://com.apple.documentation/documentation/objectivec/no>.
134 #[unsafe(method(isRouteActive:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn isRouteActive(&self, route: &AVCustomDeviceRoute) -> bool;
137 );
138}
139
140/// Methods declared on superclass `NSObject`.
141impl AVCustomRoutingController {
142 extern_methods!(
143 #[unsafe(method(init))]
144 #[unsafe(method_family = init)]
145 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
146
147 #[unsafe(method(new))]
148 #[unsafe(method_family = new)]
149 pub unsafe fn new() -> Retained<Self>;
150 );
151}
152
153extern_protocol!(
154 /// A protocol for delegates of a custom routing controller.
155 ///
156 /// See also [Apple's documentation](https://developer.apple.com/documentation/avrouting/avcustomroutingcontrollerdelegate?language=objc)
157 pub unsafe trait AVCustomRoutingControllerDelegate:
158 NSObjectProtocol + Send + Sync
159 {
160 #[cfg(all(feature = "AVCustomRoutingEvent", feature = "block2"))]
161 /// Connects to, or disconnects from, a device when a user requests it in the
162 /// picker.
163 ///
164 /// - Parameters:
165 /// - controller: A custom routing controller.
166 ///
167 /// - event: The routing event to handle.
168 ///
169 /// - completionHandler: A completion handler to call after processing the
170 /// event. Pass
171 /// <doc
172 /// ://com.apple.documentation/documentation/objectivec/yes> to
173 /// the completion handler if the activation, reactivation, or deactivation of
174 /// the route succeeds, and
175 /// <doc
176 /// ://com.apple.documentation/documentation/objectivec/no>, otherwise.
177 #[unsafe(method(customRoutingController:handleEvent:completionHandler:))]
178 #[unsafe(method_family = none)]
179 unsafe fn customRoutingController_handleEvent_completionHandler(
180 &self,
181 controller: &AVCustomRoutingController,
182 event: &AVCustomRoutingEvent,
183 completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
184 );
185
186 #[cfg(feature = "AVCustomRoutingEvent")]
187 /// Tells the delegate when a routing event times out.
188 ///
189 /// Adopt this method to clean up any in-progress connection attempts.
190 ///
191 /// - Parameters:
192 /// - controller: A custom routing controller.
193 ///
194 /// - event: An event that times out.
195 #[optional]
196 #[unsafe(method(customRoutingController:eventDidTimeOut:))]
197 #[unsafe(method_family = none)]
198 unsafe fn customRoutingController_eventDidTimeOut(
199 &self,
200 controller: &AVCustomRoutingController,
201 event: &AVCustomRoutingEvent,
202 );
203
204 #[cfg(feature = "AVCustomRoutingActionItem")]
205 /// Tells the delegate when a user selects a custom item in the route picker.
206 ///
207 /// - Parameters:
208 /// - controller: A custom routing controller.
209 ///
210 /// - customActionItem: The selected action item.
211 #[optional]
212 #[unsafe(method(customRoutingController:didSelectItem:))]
213 #[unsafe(method_family = none)]
214 unsafe fn customRoutingController_didSelectItem(
215 &self,
216 controller: &AVCustomRoutingController,
217 custom_action_item: &AVCustomRoutingActionItem,
218 );
219 }
220);
221
222extern_class!(
223 /// Represents a full or partial IP address.
224 ///
225 /// Use this class in conjunction with ``knownRouteIPs``.
226 ///
227 /// See also [Apple's documentation](https://developer.apple.com/documentation/avrouting/avcustomroutingpartialip?language=objc)
228 #[unsafe(super(NSObject))]
229 #[derive(Debug, PartialEq, Eq, Hash)]
230 pub struct AVCustomRoutingPartialIP;
231);
232
233unsafe impl Send for AVCustomRoutingPartialIP {}
234
235unsafe impl Sync for AVCustomRoutingPartialIP {}
236
237extern_conformance!(
238 unsafe impl NSObjectProtocol for AVCustomRoutingPartialIP {}
239);
240
241impl AVCustomRoutingPartialIP {
242 extern_methods!(
243 /// A full or partial IP address for a device known to be on the network.
244 ///
245 /// Use the following code to create a full known IP address.
246 ///
247 /// ```var anIPAddressInBytes:[Byte] = [192, 168, 10, 5]
248 /// var address = Data(bytes: anAddressInBytes, length: anAddressInBytes.count)
249 /// var aMaskInBytes:[Byte] = [255, 255, 255, 255]
250 /// var mask = Data(bytes: aMaskInBytes, length: aMaskInBytes.count)
251 /// var partialIP = AVCustomRoutingPartialIP(address: address, mask: mask)
252 /// ```
253 ///
254 /// This property is not atomic.
255 ///
256 /// # Safety
257 ///
258 /// This might not be thread-safe.
259 #[unsafe(method(address))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn address(&self) -> Retained<NSData>;
262
263 /// A mask representing how many octets of the IP address to respect.
264 ///
265 /// Use this mask to pass the last two bytes of the IP address instead of passing all four bytes.
266 ///
267 /// ```var anIPAddressInBytes:[Byte] = [0, 0, 10, 5]
268 /// var address = Data(bytes: anAddressInBytes, length: anAddressInBytes.count)
269 /// var aMaskInBytes:[Byte] = [0, 0, 255, 255]
270 /// var mask = Data(bytes: aMaskInBytes, length: aMaskInBytes.count)
271 /// var partialIP =AVCustomRoutingPartialIP(address: address, mask: mask)
272 /// ```
273 ///
274 /// This property is not atomic.
275 ///
276 /// # Safety
277 ///
278 /// This might not be thread-safe.
279 #[unsafe(method(mask))]
280 #[unsafe(method_family = none)]
281 pub unsafe fn mask(&self) -> Retained<NSData>;
282
283 /// Creates an IP fragment.
284 /// - Parameters:
285 /// - address: The IP address.
286 /// - mask: The address mask.
287 #[unsafe(method(initWithAddress:mask:))]
288 #[unsafe(method_family = init)]
289 pub unsafe fn initWithAddress_mask(
290 this: Allocated<Self>,
291 address: &NSData,
292 mask: &NSData,
293 ) -> Retained<Self>;
294
295 #[unsafe(method(init))]
296 #[unsafe(method_family = init)]
297 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
298
299 #[unsafe(method(new))]
300 #[unsafe(method_family = new)]
301 pub unsafe fn new() -> Retained<Self>;
302 );
303}