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