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