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