objc2_thread_network/generated/
THClient.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_class!(
11    /// A class that supports safely sharing Thread credentials between multiple
12    /// clients.
13    ///
14    /// Request credentials for either a specific Thread network or for the
15    /// _preferred network_ using `THClient`. The preferred network is the default
16    /// Thread network chosen by the framework for a home.
17    ///
18    /// The ThreadNetwork framework maintains a database of network credentials. The
19    /// class allows clients to store, list, and delete credentials for a given
20    /// network from the database.
21    ///
22    /// Some methods in `THClient` use the _team ID_, a string that you store in
23    /// your application’s `Info.plist`. The ThreadNetwork framework uses the team
24    /// ID to preserve the privacy of the Thread network credentials across
25    /// different clients. For example, credentials stored by one client can’t be
26    /// deleted or modified by another client.
27    ///
28    /// - Important: Thread credentials give you the ability to add any device into
29    /// the Thread network. Use this information responsibly.
30    ///
31    /// See also [Apple's documentation](https://developer.apple.com/documentation/threadnetwork/thclient?language=objc)
32    #[unsafe(super(NSObject))]
33    #[derive(Debug, PartialEq, Eq, Hash)]
34    pub struct THClient;
35);
36
37extern_conformance!(
38    unsafe impl NSObjectProtocol for THClient {}
39);
40
41impl THClient {
42    extern_methods!(
43        /// Creates the client object.
44        ///
45        /// - Returns: An instance of the client object.
46        #[unsafe(method(init))]
47        #[unsafe(method_family = init)]
48        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
49
50        #[cfg(all(feature = "THCredentials", feature = "block2"))]
51        /// Requests all Thread credentials from the framework.
52        ///
53        /// The framework identifies the developer by the team ID. When calling this
54        /// method, you receive credentials for your team ID only.
55        ///
56        /// - Parameters:
57        /// - completion: The completion handler the framework calls when the
58        /// credentials become available.
59        ///
60        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
61        /// > as shown on this page, or you can call it as an asynchronous method that has the
62        /// > following declaration:
63        /// >
64        /// > ```swift
65        /// > func allCredentials() async throws -> Set
66        /// <THCredentials
67        /// >
68        /// > ```
69        /// >
70        /// > For information about concurrency and asynchronous code in Swift, see
71        /// <doc
72        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
73        #[unsafe(method(retrieveAllCredentials:))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn retrieveAllCredentials(
76            &self,
77            completion: &block2::DynBlock<dyn Fn(*mut NSSet<THCredentials>, *mut NSError)>,
78        );
79
80        #[cfg(all(feature = "THCredentials", feature = "block2"))]
81        /// Requests all Thread credentials with active border routers around from the framework.
82        ///
83        /// The framework identifies the developer by the team ID. When calling this
84        /// method, you will receive credentials for active border routers around.
85        /// You receive credentials for your team ID only.
86        ///
87        /// - Parameters:
88        /// - completion: The completion handler the framework calls when the
89        /// credentials become available.
90        ///
91        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
92        /// > as shown on this page, or you can call it as an asynchronous method that has the
93        /// > following declaration:
94        /// >
95        /// > ```swift
96        /// > func allActiveCredentials() async throws -> Set
97        /// <THCredentials
98        /// >
99        /// > ```
100        /// >
101        /// > For information about concurrency and asynchronous code in Swift, see
102        /// <doc
103        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
104        #[unsafe(method(retrieveAllActiveCredentials:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn retrieveAllActiveCredentials(
107            &self,
108            completion: &block2::DynBlock<dyn Fn(*mut NSSet<THCredentials>, *mut NSError)>,
109        );
110
111        #[cfg(feature = "block2")]
112        /// Deletes Thread network credentials from the framework database for a Border
113        /// Agent.
114        ///
115        /// The Border Agent is the software component running in the Border Router
116        /// responsible for advertising itself in the Wi-Fi or Ethernet network.
117        ///
118        /// - Parameters:
119        /// - borderAgentID: The identifer of a Thread network Border Agent.
120        /// - completion: The completion handler the framework calls after deleting
121        /// the credentials.
122        ///
123        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
124        /// > as shown on this page, or you can call it as an asynchronous method that has the
125        /// > following declaration:
126        /// >
127        /// > ```swift
128        /// > func deleteCredentials(forBorderAgent borderAgentID: Data) async throws
129        /// > ```
130        /// >
131        /// > For information about concurrency and asynchronous code in Swift, see
132        /// <doc
133        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
134        #[unsafe(method(deleteCredentialsForBorderAgent:completion:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn deleteCredentialsForBorderAgent_completion(
137            &self,
138            border_agent_id: &NSData,
139            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
140        );
141
142        #[cfg(all(feature = "THCredentials", feature = "block2"))]
143        /// Requests Thread credentials for a Border Agent.
144        ///
145        /// The framework identifies the developer by the team ID. When calling this
146        /// method, you receive credentials for your team ID only.
147        ///
148        /// - Parameters:
149        /// - borderAgentID: The identifer of a Thread network Border Agent.
150        /// - completion: The completion handler the framework calls when the
151        /// credentials become available.
152        ///
153        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
154        /// > as shown on this page, or you can call it as an asynchronous method that has the
155        /// > following declaration:
156        /// >
157        /// > ```swift
158        /// > func credentials(forBorderAgentID borderAgentID: Data) async throws -> THCredentials
159        /// > ```
160        /// >
161        /// > For information about concurrency and asynchronous code in Swift, see
162        /// <doc
163        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
164        #[unsafe(method(retrieveCredentialsForBorderAgent:completion:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn retrieveCredentialsForBorderAgent_completion(
167            &self,
168            border_agent_id: &NSData,
169            completion: &block2::DynBlock<dyn Fn(*mut THCredentials, *mut NSError)>,
170        );
171
172        #[cfg(feature = "block2")]
173        /// Stores Thread network credentials into the framework database
174        /// that a Border Agent provides.
175        ///
176        /// The Border Agent is the software component running in the
177        /// Border Router responsible for advertising itself in the Wi-Fi
178        /// or Ethernet network.
179        ///
180        /// The framework only stores credentials if it can find an mDNS
181        /// record for the Border Agent that contains the specified Border
182        /// Agent identifier.
183        ///
184        /// - Parameters:
185        /// - borderAgentID: The identifer of an active Thread network Border Agent.
186        /// - activeOperationalDataSet: The essential operational parameters for the
187        /// Thread network.
188        /// - completion: The completion handler the framework calls after
189        /// storing the credentials.
190        ///
191        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
192        /// > as shown on this page, or you can call it as an asynchronous method that has the
193        /// > following declaration:
194        /// >
195        /// > ```swift
196        /// > func storeCredentials(forBorderAgent borderAgentID: Data, activeOperationalDataSet: Data) async throws
197        /// > ```
198        /// >
199        /// > For information about concurrency and asynchronous code in Swift, see
200        /// <doc
201        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
202        #[unsafe(method(storeCredentialsForBorderAgent:activeOperationalDataSet:completion:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn storeCredentialsForBorderAgent_activeOperationalDataSet_completion(
205            &self,
206            border_agent_id: &NSData,
207            active_operational_data_set: &NSData,
208            completion: &block2::DynBlock<dyn Fn(*mut NSError)>,
209        );
210
211        #[cfg(all(feature = "THCredentials", feature = "block2"))]
212        /// Requests Thread credentials for the preferred network.
213        ///
214        /// When you call this method, an alert appears asking for user permission to
215        /// access credentials.
216        ///
217        /// - Parameters:
218        /// - completion: The completion handler the framework calls when the
219        /// credentials become available.
220        ///
221        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
222        /// > as shown on this page, or you can call it as an asynchronous method that has the
223        /// > following declaration:
224        /// >
225        /// > ```swift
226        /// > func preferredCredentials() async throws -> THCredentials
227        /// > ```
228        /// >
229        /// > For information about concurrency and asynchronous code in Swift, see
230        /// <doc
231        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
232        #[unsafe(method(retrievePreferredCredentials:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn retrievePreferredCredentials(
235            &self,
236            completion: &block2::DynBlock<dyn Fn(*mut THCredentials, *mut NSError)>,
237        );
238
239        #[cfg(all(feature = "THCredentials", feature = "block2"))]
240        /// Requests Thread credentials for an extended Personal Area Network (PAN) ID.
241        ///
242        /// When calling this method, an alert appears asking for user permission to
243        /// access credentials.
244        ///
245        /// - Parameters:
246        /// - extendedPANID: The extended PAN identifier.
247        /// - completion: The completion handler the framework calls when the
248        /// credentials become available.
249        ///
250        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
251        /// > as shown on this page, or you can call it as an asynchronous method that has the
252        /// > following declaration:
253        /// >
254        /// > ```swift
255        /// > func credentials(forExtendedPANID extendedPANID: Data) async throws -> THCredentials
256        /// > ```
257        /// >
258        /// > For information about concurrency and asynchronous code in Swift, see
259        /// <doc
260        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
261        #[unsafe(method(retrieveCredentialsForExtendedPANID:completion:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn retrieveCredentialsForExtendedPANID_completion(
264            &self,
265            extended_panid: &NSData,
266            completion: &block2::DynBlock<dyn Fn(*mut THCredentials, *mut NSError)>,
267        );
268
269        #[cfg(feature = "block2")]
270        /// Determines if the essential operating parameters match the preferred
271        /// network’s parameters.
272        ///
273        /// - Parameters:
274        /// - activeOperationalDataSet: The essential operating parameters to compare
275        /// against the preferred network’s parameters.
276        /// - completion: The completion handler that returns the result of the
277        /// comparison.
278        ///
279        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
280        /// > as shown on this page, or you can call it as an asynchronous method that has the
281        /// > following declaration:
282        /// >
283        /// > ```swift
284        /// > func isPreferred(forActiveOperationalDataset activeOperationalDataSet: Data) async -> Bool
285        /// > ```
286        /// >
287        /// > For information about concurrency and asynchronous code in Swift, see
288        /// <doc
289        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
290        #[unsafe(method(checkPreferredNetworkForActiveOperationalDataset:completion:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn checkPreferredNetworkForActiveOperationalDataset_completion(
293            &self,
294            active_operational_data_set: &NSData,
295            completion: &block2::DynBlock<dyn Fn(Bool)>,
296        );
297
298        #[cfg(feature = "block2")]
299        /// Determines if the preferred network is available or not
300        ///
301        /// - Parameters:
302        /// - completion: The completion handler that returns the result of the
303        /// preferred network availability.
304        ///
305        /// > Concurrency Note: You can call this method from synchronous code using a completion handler,
306        /// > as shown on this page, or you can call it as an asynchronous method that has the
307        /// > following declaration:
308        /// >
309        /// > ```swift
310        /// > func isPreferredAvailable() async -> Bool
311        /// > ```
312        /// >
313        /// > For information about concurrency and asynchronous code in Swift, see
314        /// <doc
315        /// ://com.apple.documentation/documentation/swift/calling-objective-c-apis-asynchronously>.
316        #[unsafe(method(isPreferredNetworkAvailableWithCompletion:))]
317        #[unsafe(method_family = none)]
318        pub unsafe fn isPreferredNetworkAvailableWithCompletion(
319            &self,
320            completion: &block2::DynBlock<dyn Fn(Bool)>,
321        );
322    );
323}
324
325/// Methods declared on superclass `NSObject`.
326impl THClient {
327    extern_methods!(
328        #[unsafe(method(new))]
329        #[unsafe(method_family = new)]
330        pub unsafe fn new() -> Retained<Self>;
331    );
332}