1
-// This file was autogenerated by some hot garbage in the `uniffi` crate.
2
-// Trust me, you don't want to mess with it!
3
-
4
-// swiftlint:disable all
5
-import Foundation
6
-
7
-// Depending on the consumer's build setup, the low-level FFI code
8
-// might be in a separate module, or it might be compiled inline into
9
-// this module. This is a bit of light hackery to work with both.
10
-#if canImport(smbcloud_authFFI)
11
-import smbcloud_authFFI
12
-#endif
13
-
14
-fileprivate extension RustBuffer {
15
- // Allocate a new buffer, copying the contents of a `UInt8` array.
16
- init(bytes: [UInt8]) {
17
- let rbuf = bytes.withUnsafeBufferPointer { ptr in
18
- RustBuffer.from(ptr)
19
- }
20
- self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
21
- }
22
-
23
- static func empty() -> RustBuffer {
24
- RustBuffer(capacity: 0, len:0, data: nil)
25
- }
26
-
27
- static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
28
- try! rustCall { ffi_smbcloud_auth_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
29
- }
30
-
31
- // Frees the buffer in place.
32
- // The buffer must not be used after this is called.
33
- func deallocate() {
34
- try! rustCall { ffi_smbcloud_auth_rustbuffer_free(self, $0) }
35
- }
36
-}
37
-
38
-fileprivate extension ForeignBytes {
39
- init(bufferPointer: UnsafeBufferPointer<UInt8>) {
40
- self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
41
- }
42
-}
43
-
44
-// For every type used in the interface, we provide helper methods for conveniently
45
-// lifting and lowering that type from C-compatible data, and for reading and writing
46
-// values of that type in a buffer.
47
-
48
-// Helper classes/extensions that don't change.
49
-// Someday, this will be in a library of its own.
50
-
51
-fileprivate extension Data {
52
- init(rustBuffer: RustBuffer) {
53
- self.init(
54
- bytesNoCopy: rustBuffer.data!,
55
- count: Int(rustBuffer.len),
56
- deallocator: .none
57
- )
58
- }
59
-}
60
-
61
-// Define reader functionality. Normally this would be defined in a class or
62
-// struct, but we use standalone functions instead in order to make external
63
-// types work.
64
-//
65
-// With external types, one swift source file needs to be able to call the read
66
-// method on another source file's FfiConverter, but then what visibility
67
-// should Reader have?
68
-// - If Reader is fileprivate, then this means the read() must also
69
-// be fileprivate, which doesn't work with external types.
70
-// - If Reader is internal/public, we'll get compile errors since both source
71
-// files will try define the same type.
72
-//
73
-// Instead, the read() method and these helper functions input a tuple of data
74
-
75
-fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
76
- (data: data, offset: 0)
77
-}
78
-
79
-// Reads an integer at the current offset, in big-endian order, and advances
80
-// the offset on success. Throws if reading the integer would move the
81
-// offset past the end of the buffer.
82
-fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
83
- let range = reader.offset..<reader.offset + MemoryLayout<T>.size
84
- guard reader.data.count >= range.upperBound else {
85
- throw UniffiInternalError.bufferOverflow
86
- }
87
- if T.self == UInt8.self {
88
- let value = reader.data[reader.offset]
89
- reader.offset += 1
90
- return value as! T
91
- }
92
- var value: T = 0
93
- let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
94
- reader.offset = range.upperBound
95
- return value.bigEndian
96
-}
97
-
98
-// Reads an arbitrary number of bytes, to be used to read
99
-// raw bytes, this is useful when lifting strings
100
-fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
101
- let range = reader.offset..<(reader.offset+count)
102
- guard reader.data.count >= range.upperBound else {
103
- throw UniffiInternalError.bufferOverflow
104
- }
105
- var value = [UInt8](repeating: 0, count: count)
106
- value.withUnsafeMutableBufferPointer({ buffer in
107
- reader.data.copyBytes(to: buffer, from: range)
108
- })
109
- reader.offset = range.upperBound
110
- return value
111
-}
112
-
113
-// Reads a float at the current offset.
114
-fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
115
- return Float(bitPattern: try readInt(&reader))
116
-}
117
-
118
-// Reads a float at the current offset.
119
-fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
120
- return Double(bitPattern: try readInt(&reader))
121
-}
122
-
123
-// Indicates if the offset has reached the end of the buffer.
124
-fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
125
- return reader.offset < reader.data.count
126
-}
127
-
128
-// Define writer functionality. Normally this would be defined in a class or
129
-// struct, but we use standalone functions instead in order to make external
130
-// types work. See the above discussion on Readers for details.
131
-
132
-fileprivate func createWriter() -> [UInt8] {
133
- return []
134
-}
135
-
136
-fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
137
- writer.append(contentsOf: byteArr)
138
-}
139
-
140
-// Writes an integer in big-endian order.
141
-//
142
-// Warning: make sure what you are trying to write
143
-// is in the correct type!
144
-fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
145
- var value = value.bigEndian
146
- withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
147
-}
148
-
149
-fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
150
- writeInt(&writer, value.bitPattern)
151
-}
152
-
153
-fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
154
- writeInt(&writer, value.bitPattern)
155
-}
156
-
157
-// Protocol for types that transfer other types across the FFI. This is
158
-// analogous to the Rust trait of the same name.
159
-fileprivate protocol FfiConverter {
160
- associatedtype FfiType
161
- associatedtype SwiftType
162
-
163
- static func lift(_ value: FfiType) throws -> SwiftType
164
- static func lower(_ value: SwiftType) -> FfiType
165
- static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
166
- static func write(_ value: SwiftType, into buf: inout [UInt8])
167
-}
168
-
169
-// Types conforming to `Primitive` pass themselves directly over the FFI.
170
-fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
171
-
172
-extension FfiConverterPrimitive {
173
-#if swift(>=5.8)
174
- @_documentation(visibility: private)
175
-#endif
176
- public static func lift(_ value: FfiType) throws -> SwiftType {
177
- return value
178
- }
179
-
180
-#if swift(>=5.8)
181
- @_documentation(visibility: private)
182
-#endif
183
- public static func lower(_ value: SwiftType) -> FfiType {
184
- return value
185
- }
186
-}
187
-
188
-// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
189
-// Used for complex types where it's hard to write a custom lift/lower.
190
-fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
191
-
192
-extension FfiConverterRustBuffer {
193
-#if swift(>=5.8)
194
- @_documentation(visibility: private)
195
-#endif
196
- public static func lift(_ buf: RustBuffer) throws -> SwiftType {
197
- var reader = createReader(data: Data(rustBuffer: buf))
198
- let value = try read(from: &reader)
199
- if hasRemaining(reader) {
200
- throw UniffiInternalError.incompleteData
201
- }
202
- buf.deallocate()
203
- return value
204
- }
205
-
206
-#if swift(>=5.8)
207
- @_documentation(visibility: private)
208
-#endif
209
- public static func lower(_ value: SwiftType) -> RustBuffer {
210
- var writer = createWriter()
211
- write(value, into: &writer)
212
- return RustBuffer(bytes: writer)
213
- }
214
-}
215
-// An error type for FFI errors. These errors occur at the UniFFI level, not
216
-// the library level.
217
-fileprivate enum UniffiInternalError: LocalizedError {
218
- case bufferOverflow
219
- case incompleteData
220
- case unexpectedOptionalTag
221
- case unexpectedEnumCase
222
- case unexpectedNullPointer
223
- case unexpectedRustCallStatusCode
224
- case unexpectedRustCallError
225
- case unexpectedStaleHandle
226
- case rustPanic(_ message: String)
227
-
228
- public var errorDescription: String? {
229
- switch self {
230
- case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
231
- case .incompleteData: return "The buffer still has data after lifting its containing value"
232
- case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
233
- case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
234
- case .unexpectedNullPointer: return "Raw pointer value was null"
235
- case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
236
- case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
237
- case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
238
- case let .rustPanic(message): return message
239
- }
240
- }
241
-}
242
-
243
-fileprivate extension NSLock {
244
- func withLock<T>(f: () throws -> T) rethrows -> T {
245
- self.lock()
246
- defer { self.unlock() }
247
- return try f()
248
- }
249
-}
250
-
251
-fileprivate let CALL_SUCCESS: Int8 = 0
252
-fileprivate let CALL_ERROR: Int8 = 1
253
-fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
254
-fileprivate let CALL_CANCELLED: Int8 = 3
255
-
256
-fileprivate extension RustCallStatus {
257
- init() {
258
- self.init(
259
- code: CALL_SUCCESS,
260
- errorBuf: RustBuffer.init(
261
- capacity: 0,
262
- len: 0,
263
- data: nil
264
- )
265
- )
266
- }
267
-}
268
-
269
-private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
270
- let neverThrow: ((RustBuffer) throws -> Never)? = nil
271
- return try makeRustCall(callback, errorHandler: neverThrow)
272
-}
273
-
274
-private func rustCallWithError<T, E: Swift.Error>(
275
- _ errorHandler: @escaping (RustBuffer) throws -> E,
276
- _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
277
- try makeRustCall(callback, errorHandler: errorHandler)
278
-}
279
-
280
-private func makeRustCall<T, E: Swift.Error>(
281
- _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
282
- errorHandler: ((RustBuffer) throws -> E)?
283
-) throws -> T {
284
- uniffiEnsureSmbcloudAuthInitialized()
285
- var callStatus = RustCallStatus.init()
286
- let returnedVal = callback(&callStatus)
287
- try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
288
- return returnedVal
289
-}
290
-
291
-private func uniffiCheckCallStatus<E: Swift.Error>(
292
- callStatus: RustCallStatus,
293
- errorHandler: ((RustBuffer) throws -> E)?
294
-) throws {
295
- switch callStatus.code {
296
- case CALL_SUCCESS:
297
- return
298
-
299
- case CALL_ERROR:
300
- if let errorHandler = errorHandler {
301
- throw try errorHandler(callStatus.errorBuf)
302
- } else {
303
- callStatus.errorBuf.deallocate()
304
- throw UniffiInternalError.unexpectedRustCallError
305
- }
306
-
307
- case CALL_UNEXPECTED_ERROR:
308
- // When the rust code sees a panic, it tries to construct a RustBuffer
309
- // with the message. But if that code panics, then it just sends back
310
- // an empty buffer.
311
- if callStatus.errorBuf.len > 0 {
312
- throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
313
- } else {
314
- callStatus.errorBuf.deallocate()
315
- throw UniffiInternalError.rustPanic("Rust panic")
316
- }
317
-
318
- case CALL_CANCELLED:
319
- fatalError("Cancellation not supported yet")
320
-
321
- default:
322
- throw UniffiInternalError.unexpectedRustCallStatusCode
323
- }
324
-}
325
-
326
-private func uniffiTraitInterfaceCall<T>(
327
- callStatus: UnsafeMutablePointer<RustCallStatus>,
328
- makeCall: () throws -> T,
329
- writeReturn: (T) -> ()
330
-) {
331
- do {
332
- try writeReturn(makeCall())
333
- } catch let error {
334
- callStatus.pointee.code = CALL_UNEXPECTED_ERROR
335
- callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
336
- }
337
-}
338
-
339
-private func uniffiTraitInterfaceCallWithError<T, E>(
340
- callStatus: UnsafeMutablePointer<RustCallStatus>,
341
- makeCall: () throws -> T,
342
- writeReturn: (T) -> (),
343
- lowerError: (E) -> RustBuffer
344
-) {
345
- do {
346
- try writeReturn(makeCall())
347
- } catch let error as E {
348
- callStatus.pointee.code = CALL_ERROR
349
- callStatus.pointee.errorBuf = lowerError(error)
350
- } catch {
351
- callStatus.pointee.code = CALL_UNEXPECTED_ERROR
352
- callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
353
- }
354
-}
355
-fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
356
- // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
357
- private let lock = NSLock()
358
- private var map: [UInt64: T] = [:]
359
- private var currentHandle: UInt64 = 1
360
-
361
- func insert(obj: T) -> UInt64 {
362
- lock.withLock {
363
- let handle = currentHandle
364
- currentHandle += 1
365
- map[handle] = obj
366
- return handle
367
- }
368
- }
369
-
370
- func get(handle: UInt64) throws -> T {
371
- try lock.withLock {
372
- guard let obj = map[handle] else {
373
- throw UniffiInternalError.unexpectedStaleHandle
374
- }
375
- return obj
376
- }
377
- }
378
-
379
- @discardableResult
380
- func remove(handle: UInt64) throws -> T {
381
- try lock.withLock {
382
- guard let obj = map.removeValue(forKey: handle) else {
383
- throw UniffiInternalError.unexpectedStaleHandle
384
- }
385
- return obj
386
- }
387
- }
388
-
389
- var count: Int {
390
- get {
391
- map.count
392
- }
393
- }
394
-}
395
-
396
-
397
-// Public interface members begin here.
398
-
399
-
400
-#if swift(>=5.8)
401
-@_documentation(visibility: private)
402
-#endif
403
-fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
404
- typealias FfiType = UInt32
405
- typealias SwiftType = UInt32
406
-
407
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
408
- return try lift(readInt(&buf))
409
- }
410
-
411
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
412
- writeInt(&buf, lower(value))
413
- }
414
-}
415
-
416
-#if swift(>=5.8)
417
-@_documentation(visibility: private)
418
-#endif
419
-fileprivate struct FfiConverterInt32: FfiConverterPrimitive {
420
- typealias FfiType = Int32
421
- typealias SwiftType = Int32
422
-
423
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int32 {
424
- return try lift(readInt(&buf))
425
- }
426
-
427
- public static func write(_ value: Int32, into buf: inout [UInt8]) {
428
- writeInt(&buf, lower(value))
429
- }
430
-}
431
-
432
-#if swift(>=5.8)
433
-@_documentation(visibility: private)
434
-#endif
435
-fileprivate struct FfiConverterUInt64: FfiConverterPrimitive {
436
- typealias FfiType = UInt64
437
- typealias SwiftType = UInt64
438
-
439
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
440
- return try lift(readInt(&buf))
441
- }
442
-
443
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
444
- writeInt(&buf, lower(value))
445
- }
446
-}
447
-
448
-#if swift(>=5.8)
449
-@_documentation(visibility: private)
450
-#endif
451
-fileprivate struct FfiConverterBool : FfiConverter {
452
- typealias FfiType = Int8
453
- typealias SwiftType = Bool
454
-
455
- public static func lift(_ value: Int8) throws -> Bool {
456
- return value != 0
457
- }
458
-
459
- public static func lower(_ value: Bool) -> Int8 {
460
- return value ? 1 : 0
461
- }
462
-
463
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
464
- return try lift(readInt(&buf))
465
- }
466
-
467
- public static func write(_ value: Bool, into buf: inout [UInt8]) {
468
- writeInt(&buf, lower(value))
469
- }
470
-}
471
-
472
-#if swift(>=5.8)
473
-@_documentation(visibility: private)
474
-#endif
475
-fileprivate struct FfiConverterString: FfiConverter {
476
- typealias SwiftType = String
477
- typealias FfiType = RustBuffer
478
-
479
- public static func lift(_ value: RustBuffer) throws -> String {
480
- defer {
481
- value.deallocate()
482
- }
483
- if value.data == nil {
484
- return String()
485
- }
486
- let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
487
- return String(bytes: bytes, encoding: String.Encoding.utf8)!
488
- }
489
-
490
- public static func lower(_ value: String) -> RustBuffer {
491
- return value.utf8CString.withUnsafeBufferPointer { ptr in
492
- // The swift string gives us int8_t, we want uint8_t.
493
- ptr.withMemoryRebound(to: UInt8.self) { ptr in
494
- // The swift string gives us a trailing null byte, we don't want it.
495
- let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
496
- return RustBuffer.from(buf)
497
- }
498
- }
499
- }
500
-
501
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
502
- let len: Int32 = try readInt(&buf)
503
- return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
504
- }
505
-
506
- public static func write(_ value: String, into buf: inout [UInt8]) {
507
- let len = Int32(value.utf8.count)
508
- writeInt(&buf, len)
509
- writeBytes(&buf, value.utf8)
510
- }
511
-}
512
-
513
-
514
-
515
-
516
-public protocol SmbCloudAuthProtocol: AnyObject, Sendable {
517
-
518
- func buildAppleAuthorizationRequest(redirectUri: String, state: String?) throws -> SmbCloudAppleAuthorizationRequest
519
-
520
- func buildOidcAuthorizationRequest(oidcClientId: String, redirectUri: String) throws -> SmbCloudAuthorizationRequest
521
-
522
- func exchangeOidcCode(oidcClientId: String, redirectUri: String, code: String, codeVerifier: String) async throws -> SmbCloudTokenResponse
523
-
524
- func getOidcUserinfo(accessToken: String, tenantId: String?) async throws -> SmbCloudUserInfo
525
-
526
- func login(email: String, password: String) async throws -> SmbCloudAccountStatus
527
-
528
- func logout(accessToken: String) async throws
529
-
530
- func me(accessToken: String) async throws -> SmbCloudUser
531
-
532
- func parseAppleCallbackUrl(callbackUrl: String, expectedState: String?) throws -> SmbCloudAppleAuthSession
533
-
534
- func parseOidcCallbackUrl(callbackUrl: String) throws -> SmbCloudCallbackPayload
535
-
536
- func removeAccount(accessToken: String) async throws
537
-
538
- func signup(email: String, password: String) async throws -> SmbCloudSignupResult
539
-
540
-}
541
-open class SmbCloudAuth: SmbCloudAuthProtocol, @unchecked Sendable {
542
- fileprivate let pointer: UnsafeMutableRawPointer!
543
-
544
- /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
545
-#if swift(>=5.8)
546
- @_documentation(visibility: private)
547
-#endif
548
- public struct NoPointer {
549
- public init() {}
550
- }
551
-
552
- // TODO: We'd like this to be `private` but for Swifty reasons,
553
- // we can't implement `FfiConverter` without making this `required` and we can't
554
- // make it `required` without making it `public`.
555
-#if swift(>=5.8)
556
- @_documentation(visibility: private)
557
-#endif
558
- required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
559
- self.pointer = pointer
560
- }
561
-
562
- // This constructor can be used to instantiate a fake object.
563
- // - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
564
- //
565
- // - Warning:
566
- // Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
567
-#if swift(>=5.8)
568
- @_documentation(visibility: private)
569
-#endif
570
- public init(noPointer: NoPointer) {
571
- self.pointer = nil
572
- }
573
-
574
-#if swift(>=5.8)
575
- @_documentation(visibility: private)
576
-#endif
577
- public func uniffiClonePointer() -> UnsafeMutableRawPointer {
578
- return try! rustCall { uniffi_smbcloud_auth_fn_clone_smbcloudauth(self.pointer, $0) }
579
- }
580
-public convenience init(environment: SmbCloudEnvironment, appId: String, appSecret: String) {
581
- let pointer =
582
- try! rustCall() {
583
- uniffi_smbcloud_auth_fn_constructor_smbcloudauth_new(
584
- FfiConverterTypeSmbCloudEnvironment_lower(environment),
585
- FfiConverterString.lower(appId),
586
- FfiConverterString.lower(appSecret),$0
587
- )
588
-}
589
- self.init(unsafeFromRawPointer: pointer)
590
-}
591
-
592
- deinit {
593
- guard let pointer = pointer else {
594
- return
595
- }
596
-
597
- try! rustCall { uniffi_smbcloud_auth_fn_free_smbcloudauth(pointer, $0) }
598
- }
599
-
600
-
601
-
602
-
603
-open func buildAppleAuthorizationRequest(redirectUri: String, state: String?)throws -> SmbCloudAppleAuthorizationRequest {
604
- return try FfiConverterTypeSmbCloudAppleAuthorizationRequest_lift(try rustCallWithError(FfiConverterTypeSmbCloudAuthError_lift) {
605
- uniffi_smbcloud_auth_fn_method_smbcloudauth_build_apple_authorization_request(self.uniffiClonePointer(),
606
- FfiConverterString.lower(redirectUri),
607
- FfiConverterOptionString.lower(state),$0
608
- )
609
-})
610
-}
611
-
612
-open func buildOidcAuthorizationRequest(oidcClientId: String, redirectUri: String)throws -> SmbCloudAuthorizationRequest {
613
- return try FfiConverterTypeSmbCloudAuthorizationRequest_lift(try rustCallWithError(FfiConverterTypeSmbCloudAuthError_lift) {
614
- uniffi_smbcloud_auth_fn_method_smbcloudauth_build_oidc_authorization_request(self.uniffiClonePointer(),
615
- FfiConverterString.lower(oidcClientId),
616
- FfiConverterString.lower(redirectUri),$0
617
- )
618
-})
619
-}
620
-
621
-open func exchangeOidcCode(oidcClientId: String, redirectUri: String, code: String, codeVerifier: String)async throws -> SmbCloudTokenResponse {
622
- return
623
- try await uniffiRustCallAsync(
624
- rustFutureFunc: {
625
- uniffi_smbcloud_auth_fn_method_smbcloudauth_exchange_oidc_code(
626
- self.uniffiClonePointer(),
627
- FfiConverterString.lower(oidcClientId),FfiConverterString.lower(redirectUri),FfiConverterString.lower(code),FfiConverterString.lower(codeVerifier)
628
- )
629
- },
630
- pollFunc: ffi_smbcloud_auth_rust_future_poll_rust_buffer,
631
- completeFunc: ffi_smbcloud_auth_rust_future_complete_rust_buffer,
632
- freeFunc: ffi_smbcloud_auth_rust_future_free_rust_buffer,
633
- liftFunc: FfiConverterTypeSmbCloudTokenResponse_lift,
634
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
635
- )
636
-}
637
-
638
-open func getOidcUserinfo(accessToken: String, tenantId: String?)async throws -> SmbCloudUserInfo {
639
- return
640
- try await uniffiRustCallAsync(
641
- rustFutureFunc: {
642
- uniffi_smbcloud_auth_fn_method_smbcloudauth_get_oidc_userinfo(
643
- self.uniffiClonePointer(),
644
- FfiConverterString.lower(accessToken),FfiConverterOptionString.lower(tenantId)
645
- )
646
- },
647
- pollFunc: ffi_smbcloud_auth_rust_future_poll_rust_buffer,
648
- completeFunc: ffi_smbcloud_auth_rust_future_complete_rust_buffer,
649
- freeFunc: ffi_smbcloud_auth_rust_future_free_rust_buffer,
650
- liftFunc: FfiConverterTypeSmbCloudUserInfo_lift,
651
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
652
- )
653
-}
654
-
655
-open func login(email: String, password: String)async throws -> SmbCloudAccountStatus {
656
- return
657
- try await uniffiRustCallAsync(
658
- rustFutureFunc: {
659
- uniffi_smbcloud_auth_fn_method_smbcloudauth_login(
660
- self.uniffiClonePointer(),
661
- FfiConverterString.lower(email),FfiConverterString.lower(password)
662
- )
663
- },
664
- pollFunc: ffi_smbcloud_auth_rust_future_poll_rust_buffer,
665
- completeFunc: ffi_smbcloud_auth_rust_future_complete_rust_buffer,
666
- freeFunc: ffi_smbcloud_auth_rust_future_free_rust_buffer,
667
- liftFunc: FfiConverterTypeSmbCloudAccountStatus_lift,
668
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
669
- )
670
-}
671
-
672
-open func logout(accessToken: String)async throws {
673
- return
674
- try await uniffiRustCallAsync(
675
- rustFutureFunc: {
676
- uniffi_smbcloud_auth_fn_method_smbcloudauth_logout(
677
- self.uniffiClonePointer(),
678
- FfiConverterString.lower(accessToken)
679
- )
680
- },
681
- pollFunc: ffi_smbcloud_auth_rust_future_poll_void,
682
- completeFunc: ffi_smbcloud_auth_rust_future_complete_void,
683
- freeFunc: ffi_smbcloud_auth_rust_future_free_void,
684
- liftFunc: { $0 },
685
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
686
- )
687
-}
688
-
689
-open func me(accessToken: String)async throws -> SmbCloudUser {
690
- return
691
- try await uniffiRustCallAsync(
692
- rustFutureFunc: {
693
- uniffi_smbcloud_auth_fn_method_smbcloudauth_me(
694
- self.uniffiClonePointer(),
695
- FfiConverterString.lower(accessToken)
696
- )
697
- },
698
- pollFunc: ffi_smbcloud_auth_rust_future_poll_rust_buffer,
699
- completeFunc: ffi_smbcloud_auth_rust_future_complete_rust_buffer,
700
- freeFunc: ffi_smbcloud_auth_rust_future_free_rust_buffer,
701
- liftFunc: FfiConverterTypeSmbCloudUser_lift,
702
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
703
- )
704
-}
705
-
706
-open func parseAppleCallbackUrl(callbackUrl: String, expectedState: String?)throws -> SmbCloudAppleAuthSession {
707
- return try FfiConverterTypeSmbCloudAppleAuthSession_lift(try rustCallWithError(FfiConverterTypeSmbCloudAuthError_lift) {
708
- uniffi_smbcloud_auth_fn_method_smbcloudauth_parse_apple_callback_url(self.uniffiClonePointer(),
709
- FfiConverterString.lower(callbackUrl),
710
- FfiConverterOptionString.lower(expectedState),$0
711
- )
712
-})
713
-}
714
-
715
-open func parseOidcCallbackUrl(callbackUrl: String)throws -> SmbCloudCallbackPayload {
716
- return try FfiConverterTypeSmbCloudCallbackPayload_lift(try rustCallWithError(FfiConverterTypeSmbCloudAuthError_lift) {
717
- uniffi_smbcloud_auth_fn_method_smbcloudauth_parse_oidc_callback_url(self.uniffiClonePointer(),
718
- FfiConverterString.lower(callbackUrl),$0
719
- )
720
-})
721
-}
722
-
723
-open func removeAccount(accessToken: String)async throws {
724
- return
725
- try await uniffiRustCallAsync(
726
- rustFutureFunc: {
727
- uniffi_smbcloud_auth_fn_method_smbcloudauth_remove_account(
728
- self.uniffiClonePointer(),
729
- FfiConverterString.lower(accessToken)
730
- )
731
- },
732
- pollFunc: ffi_smbcloud_auth_rust_future_poll_void,
733
- completeFunc: ffi_smbcloud_auth_rust_future_complete_void,
734
- freeFunc: ffi_smbcloud_auth_rust_future_free_void,
735
- liftFunc: { $0 },
736
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
737
- )
738
-}
739
-
740
-open func signup(email: String, password: String)async throws -> SmbCloudSignupResult {
741
- return
742
- try await uniffiRustCallAsync(
743
- rustFutureFunc: {
744
- uniffi_smbcloud_auth_fn_method_smbcloudauth_signup(
745
- self.uniffiClonePointer(),
746
- FfiConverterString.lower(email),FfiConverterString.lower(password)
747
- )
748
- },
749
- pollFunc: ffi_smbcloud_auth_rust_future_poll_rust_buffer,
750
- completeFunc: ffi_smbcloud_auth_rust_future_complete_rust_buffer,
751
- freeFunc: ffi_smbcloud_auth_rust_future_free_rust_buffer,
752
- liftFunc: FfiConverterTypeSmbCloudSignupResult_lift,
753
- errorHandler: FfiConverterTypeSmbCloudAuthError_lift
754
- )
755
-}
756
-
757
-
758
-}
759
-
760
-
761
-#if swift(>=5.8)
762
-@_documentation(visibility: private)
763
-#endif
764
-public struct FfiConverterTypeSmbCloudAuth: FfiConverter {
765
-
766
- typealias FfiType = UnsafeMutableRawPointer
767
- typealias SwiftType = SmbCloudAuth
768
-
769
- public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> SmbCloudAuth {
770
- return SmbCloudAuth(unsafeFromRawPointer: pointer)
771
- }
772
-
773
- public static func lower(_ value: SmbCloudAuth) -> UnsafeMutableRawPointer {
774
- return value.uniffiClonePointer()
775
- }
776
-
777
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAuth {
778
- let v: UInt64 = try readInt(&buf)
779
- // The Rust code won't compile if a pointer won't fit in a UInt64.
780
- // We have to go via `UInt` because that's the thing that's the size of a pointer.
781
- let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
782
- if (ptr == nil) {
783
- throw UniffiInternalError.unexpectedNullPointer
784
- }
785
- return try lift(ptr!)
786
- }
787
-
788
- public static func write(_ value: SmbCloudAuth, into buf: inout [UInt8]) {
789
- // This fiddling is because `Int` is the thing that's the same size as a pointer.
790
- // The Rust code won't compile if a pointer won't fit in a `UInt64`.
791
- writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
792
- }
793
-}
794
-
795
-
796
-#if swift(>=5.8)
797
-@_documentation(visibility: private)
798
-#endif
799
-public func FfiConverterTypeSmbCloudAuth_lift(_ pointer: UnsafeMutableRawPointer) throws -> SmbCloudAuth {
800
- return try FfiConverterTypeSmbCloudAuth.lift(pointer)
801
-}
802
-
803
-#if swift(>=5.8)
804
-@_documentation(visibility: private)
805
-#endif
806
-public func FfiConverterTypeSmbCloudAuth_lower(_ value: SmbCloudAuth) -> UnsafeMutableRawPointer {
807
- return FfiConverterTypeSmbCloudAuth.lower(value)
808
-}
809
-
810
-
811
-
812
-
813
-public struct SmbCloudAppleAuthSession {
814
- public var accessToken: String
815
- public var refreshToken: String?
816
- public var email: String?
817
- public var name: String?
818
- public var provider: String
819
- public var providerAccountId: String
820
- public var state: String?
821
-
822
- // Default memberwise initializers are never public by default, so we
823
- // declare one manually.
824
- public init(accessToken: String, refreshToken: String?, email: String?, name: String?, provider: String, providerAccountId: String, state: String?) {
825
- self.accessToken = accessToken
826
- self.refreshToken = refreshToken
827
- self.email = email
828
- self.name = name
829
- self.provider = provider
830
- self.providerAccountId = providerAccountId
831
- self.state = state
832
- }
833
-}
834
-
835
-#if compiler(>=6)
836
-extension SmbCloudAppleAuthSession: Sendable {}
837
-#endif
838
-
839
-
840
-extension SmbCloudAppleAuthSession: Equatable, Hashable {
841
- public static func ==(lhs: SmbCloudAppleAuthSession, rhs: SmbCloudAppleAuthSession) -> Bool {
842
- if lhs.accessToken != rhs.accessToken {
843
- return false
844
- }
845
- if lhs.refreshToken != rhs.refreshToken {
846
- return false
847
- }
848
- if lhs.email != rhs.email {
849
- return false
850
- }
851
- if lhs.name != rhs.name {
852
- return false
853
- }
854
- if lhs.provider != rhs.provider {
855
- return false
856
- }
857
- if lhs.providerAccountId != rhs.providerAccountId {
858
- return false
859
- }
860
- if lhs.state != rhs.state {
861
- return false
862
- }
863
- return true
864
- }
865
-
866
- public func hash(into hasher: inout Hasher) {
867
- hasher.combine(accessToken)
868
- hasher.combine(refreshToken)
869
- hasher.combine(email)
870
- hasher.combine(name)
871
- hasher.combine(provider)
872
- hasher.combine(providerAccountId)
873
- hasher.combine(state)
874
- }
875
-}
876
-
877
-
878
-
879
-#if swift(>=5.8)
880
-@_documentation(visibility: private)
881
-#endif
882
-public struct FfiConverterTypeSmbCloudAppleAuthSession: FfiConverterRustBuffer {
883
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAppleAuthSession {
884
- return
885
- try SmbCloudAppleAuthSession(
886
- accessToken: FfiConverterString.read(from: &buf),
887
- refreshToken: FfiConverterOptionString.read(from: &buf),
888
- email: FfiConverterOptionString.read(from: &buf),
889
- name: FfiConverterOptionString.read(from: &buf),
890
- provider: FfiConverterString.read(from: &buf),
891
- providerAccountId: FfiConverterString.read(from: &buf),
892
- state: FfiConverterOptionString.read(from: &buf)
893
- )
894
- }
895
-
896
- public static func write(_ value: SmbCloudAppleAuthSession, into buf: inout [UInt8]) {
897
- FfiConverterString.write(value.accessToken, into: &buf)
898
- FfiConverterOptionString.write(value.refreshToken, into: &buf)
899
- FfiConverterOptionString.write(value.email, into: &buf)
900
- FfiConverterOptionString.write(value.name, into: &buf)
901
- FfiConverterString.write(value.provider, into: &buf)
902
- FfiConverterString.write(value.providerAccountId, into: &buf)
903
- FfiConverterOptionString.write(value.state, into: &buf)
904
- }
905
-}
906
-
907
-
908
-#if swift(>=5.8)
909
-@_documentation(visibility: private)
910
-#endif
911
-public func FfiConverterTypeSmbCloudAppleAuthSession_lift(_ buf: RustBuffer) throws -> SmbCloudAppleAuthSession {
912
- return try FfiConverterTypeSmbCloudAppleAuthSession.lift(buf)
913
-}
914
-
915
-#if swift(>=5.8)
916
-@_documentation(visibility: private)
917
-#endif
918
-public func FfiConverterTypeSmbCloudAppleAuthSession_lower(_ value: SmbCloudAppleAuthSession) -> RustBuffer {
919
- return FfiConverterTypeSmbCloudAppleAuthSession.lower(value)
920
-}
921
-
922
-
923
-public struct SmbCloudAppleAuthorizationRequest {
924
- public var authorizeUrl: String
925
- public var redirectUri: String
926
- public var state: String
927
-
928
- // Default memberwise initializers are never public by default, so we
929
- // declare one manually.
930
- public init(authorizeUrl: String, redirectUri: String, state: String) {
931
- self.authorizeUrl = authorizeUrl
932
- self.redirectUri = redirectUri
933
- self.state = state
934
- }
935
-}
936
-
937
-#if compiler(>=6)
938
-extension SmbCloudAppleAuthorizationRequest: Sendable {}
939
-#endif
940
-
941
-
942
-extension SmbCloudAppleAuthorizationRequest: Equatable, Hashable {
943
- public static func ==(lhs: SmbCloudAppleAuthorizationRequest, rhs: SmbCloudAppleAuthorizationRequest) -> Bool {
944
- if lhs.authorizeUrl != rhs.authorizeUrl {
945
- return false
946
- }
947
- if lhs.redirectUri != rhs.redirectUri {
948
- return false
949
- }
950
- if lhs.state != rhs.state {
951
- return false
952
- }
953
- return true
954
- }
955
-
956
- public func hash(into hasher: inout Hasher) {
957
- hasher.combine(authorizeUrl)
958
- hasher.combine(redirectUri)
959
- hasher.combine(state)
960
- }
961
-}
962
-
963
-
964
-
965
-#if swift(>=5.8)
966
-@_documentation(visibility: private)
967
-#endif
968
-public struct FfiConverterTypeSmbCloudAppleAuthorizationRequest: FfiConverterRustBuffer {
969
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAppleAuthorizationRequest {
970
- return
971
- try SmbCloudAppleAuthorizationRequest(
972
- authorizeUrl: FfiConverterString.read(from: &buf),
973
- redirectUri: FfiConverterString.read(from: &buf),
974
- state: FfiConverterString.read(from: &buf)
975
- )
976
- }
977
-
978
- public static func write(_ value: SmbCloudAppleAuthorizationRequest, into buf: inout [UInt8]) {
979
- FfiConverterString.write(value.authorizeUrl, into: &buf)
980
- FfiConverterString.write(value.redirectUri, into: &buf)
981
- FfiConverterString.write(value.state, into: &buf)
982
- }
983
-}
984
-
985
-
986
-#if swift(>=5.8)
987
-@_documentation(visibility: private)
988
-#endif
989
-public func FfiConverterTypeSmbCloudAppleAuthorizationRequest_lift(_ buf: RustBuffer) throws -> SmbCloudAppleAuthorizationRequest {
990
- return try FfiConverterTypeSmbCloudAppleAuthorizationRequest.lift(buf)
991
-}
992
-
993
-#if swift(>=5.8)
994
-@_documentation(visibility: private)
995
-#endif
996
-public func FfiConverterTypeSmbCloudAppleAuthorizationRequest_lower(_ value: SmbCloudAppleAuthorizationRequest) -> RustBuffer {
997
- return FfiConverterTypeSmbCloudAppleAuthorizationRequest.lower(value)
998
-}
999
-
1000
-
1001
-public struct SmbCloudAuthorizationRequest {
1002
- public var authorizeUrl: String
1003
- public var redirectUri: String
1004
- public var state: String
1005
- public var codeVerifier: String
1006
-
1007
- // Default memberwise initializers are never public by default, so we
1008
- // declare one manually.
1009
- public init(authorizeUrl: String, redirectUri: String, state: String, codeVerifier: String) {
1010
- self.authorizeUrl = authorizeUrl
1011
- self.redirectUri = redirectUri
1012
- self.state = state
1013
- self.codeVerifier = codeVerifier
1014
- }
1015
-}
1016
-
1017
-#if compiler(>=6)
1018
-extension SmbCloudAuthorizationRequest: Sendable {}
1019
-#endif
1020
-
1021
-
1022
-extension SmbCloudAuthorizationRequest: Equatable, Hashable {
1023
- public static func ==(lhs: SmbCloudAuthorizationRequest, rhs: SmbCloudAuthorizationRequest) -> Bool {
1024
- if lhs.authorizeUrl != rhs.authorizeUrl {
1025
- return false
1026
- }
1027
- if lhs.redirectUri != rhs.redirectUri {
1028
- return false
1029
- }
1030
- if lhs.state != rhs.state {
1031
- return false
1032
- }
1033
- if lhs.codeVerifier != rhs.codeVerifier {
1034
- return false
1035
- }
1036
- return true
1037
- }
1038
-
1039
- public func hash(into hasher: inout Hasher) {
1040
- hasher.combine(authorizeUrl)
1041
- hasher.combine(redirectUri)
1042
- hasher.combine(state)
1043
- hasher.combine(codeVerifier)
1044
- }
1045
-}
1046
-
1047
-
1048
-
1049
-#if swift(>=5.8)
1050
-@_documentation(visibility: private)
1051
-#endif
1052
-public struct FfiConverterTypeSmbCloudAuthorizationRequest: FfiConverterRustBuffer {
1053
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAuthorizationRequest {
1054
- return
1055
- try SmbCloudAuthorizationRequest(
1056
- authorizeUrl: FfiConverterString.read(from: &buf),
1057
- redirectUri: FfiConverterString.read(from: &buf),
1058
- state: FfiConverterString.read(from: &buf),
1059
- codeVerifier: FfiConverterString.read(from: &buf)
1060
- )
1061
- }
1062
-
1063
- public static func write(_ value: SmbCloudAuthorizationRequest, into buf: inout [UInt8]) {
1064
- FfiConverterString.write(value.authorizeUrl, into: &buf)
1065
- FfiConverterString.write(value.redirectUri, into: &buf)
1066
- FfiConverterString.write(value.state, into: &buf)
1067
- FfiConverterString.write(value.codeVerifier, into: &buf)
1068
- }
1069
-}
1070
-
1071
-
1072
-#if swift(>=5.8)
1073
-@_documentation(visibility: private)
1074
-#endif
1075
-public func FfiConverterTypeSmbCloudAuthorizationRequest_lift(_ buf: RustBuffer) throws -> SmbCloudAuthorizationRequest {
1076
- return try FfiConverterTypeSmbCloudAuthorizationRequest.lift(buf)
1077
-}
1078
-
1079
-#if swift(>=5.8)
1080
-@_documentation(visibility: private)
1081
-#endif
1082
-public func FfiConverterTypeSmbCloudAuthorizationRequest_lower(_ value: SmbCloudAuthorizationRequest) -> RustBuffer {
1083
- return FfiConverterTypeSmbCloudAuthorizationRequest.lower(value)
1084
-}
1085
-
1086
-
1087
-public struct SmbCloudCallbackPayload {
1088
- public var code: String
1089
- public var state: String
1090
-
1091
- // Default memberwise initializers are never public by default, so we
1092
- // declare one manually.
1093
- public init(code: String, state: String) {
1094
- self.code = code
1095
- self.state = state
1096
- }
1097
-}
1098
-
1099
-#if compiler(>=6)
1100
-extension SmbCloudCallbackPayload: Sendable {}
1101
-#endif
1102
-
1103
-
1104
-extension SmbCloudCallbackPayload: Equatable, Hashable {
1105
- public static func ==(lhs: SmbCloudCallbackPayload, rhs: SmbCloudCallbackPayload) -> Bool {
1106
- if lhs.code != rhs.code {
1107
- return false
1108
- }
1109
- if lhs.state != rhs.state {
1110
- return false
1111
- }
1112
- return true
1113
- }
1114
-
1115
- public func hash(into hasher: inout Hasher) {
1116
- hasher.combine(code)
1117
- hasher.combine(state)
1118
- }
1119
-}
1120
-
1121
-
1122
-
1123
-#if swift(>=5.8)
1124
-@_documentation(visibility: private)
1125
-#endif
1126
-public struct FfiConverterTypeSmbCloudCallbackPayload: FfiConverterRustBuffer {
1127
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudCallbackPayload {
1128
- return
1129
- try SmbCloudCallbackPayload(
1130
- code: FfiConverterString.read(from: &buf),
1131
- state: FfiConverterString.read(from: &buf)
1132
- )
1133
- }
1134
-
1135
- public static func write(_ value: SmbCloudCallbackPayload, into buf: inout [UInt8]) {
1136
- FfiConverterString.write(value.code, into: &buf)
1137
- FfiConverterString.write(value.state, into: &buf)
1138
- }
1139
-}
1140
-
1141
-
1142
-#if swift(>=5.8)
1143
-@_documentation(visibility: private)
1144
-#endif
1145
-public func FfiConverterTypeSmbCloudCallbackPayload_lift(_ buf: RustBuffer) throws -> SmbCloudCallbackPayload {
1146
- return try FfiConverterTypeSmbCloudCallbackPayload.lift(buf)
1147
-}
1148
-
1149
-#if swift(>=5.8)
1150
-@_documentation(visibility: private)
1151
-#endif
1152
-public func FfiConverterTypeSmbCloudCallbackPayload_lower(_ value: SmbCloudCallbackPayload) -> RustBuffer {
1153
- return FfiConverterTypeSmbCloudCallbackPayload.lower(value)
1154
-}
1155
-
1156
-
1157
-public struct SmbCloudSignupResult {
1158
- public var code: Int32?
1159
- public var message: String
1160
- public var userId: Int32?
1161
- public var userEmail: String?
1162
- public var userCreatedAt: String?
1163
-
1164
- // Default memberwise initializers are never public by default, so we
1165
- // declare one manually.
1166
- public init(code: Int32?, message: String, userId: Int32?, userEmail: String?, userCreatedAt: String?) {
1167
- self.code = code
1168
- self.message = message
1169
- self.userId = userId
1170
- self.userEmail = userEmail
1171
- self.userCreatedAt = userCreatedAt
1172
- }
1173
-}
1174
-
1175
-#if compiler(>=6)
1176
-extension SmbCloudSignupResult: Sendable {}
1177
-#endif
1178
-
1179
-
1180
-extension SmbCloudSignupResult: Equatable, Hashable {
1181
- public static func ==(lhs: SmbCloudSignupResult, rhs: SmbCloudSignupResult) -> Bool {
1182
- if lhs.code != rhs.code {
1183
- return false
1184
- }
1185
- if lhs.message != rhs.message {
1186
- return false
1187
- }
1188
- if lhs.userId != rhs.userId {
1189
- return false
1190
- }
1191
- if lhs.userEmail != rhs.userEmail {
1192
- return false
1193
- }
1194
- if lhs.userCreatedAt != rhs.userCreatedAt {
1195
- return false
1196
- }
1197
- return true
1198
- }
1199
-
1200
- public func hash(into hasher: inout Hasher) {
1201
- hasher.combine(code)
1202
- hasher.combine(message)
1203
- hasher.combine(userId)
1204
- hasher.combine(userEmail)
1205
- hasher.combine(userCreatedAt)
1206
- }
1207
-}
1208
-
1209
-
1210
-
1211
-#if swift(>=5.8)
1212
-@_documentation(visibility: private)
1213
-#endif
1214
-public struct FfiConverterTypeSmbCloudSignupResult: FfiConverterRustBuffer {
1215
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudSignupResult {
1216
- return
1217
- try SmbCloudSignupResult(
1218
- code: FfiConverterOptionInt32.read(from: &buf),
1219
- message: FfiConverterString.read(from: &buf),
1220
- userId: FfiConverterOptionInt32.read(from: &buf),
1221
- userEmail: FfiConverterOptionString.read(from: &buf),
1222
- userCreatedAt: FfiConverterOptionString.read(from: &buf)
1223
- )
1224
- }
1225
-
1226
- public static func write(_ value: SmbCloudSignupResult, into buf: inout [UInt8]) {
1227
- FfiConverterOptionInt32.write(value.code, into: &buf)
1228
- FfiConverterString.write(value.message, into: &buf)
1229
- FfiConverterOptionInt32.write(value.userId, into: &buf)
1230
- FfiConverterOptionString.write(value.userEmail, into: &buf)
1231
- FfiConverterOptionString.write(value.userCreatedAt, into: &buf)
1232
- }
1233
-}
1234
-
1235
-
1236
-#if swift(>=5.8)
1237
-@_documentation(visibility: private)
1238
-#endif
1239
-public func FfiConverterTypeSmbCloudSignupResult_lift(_ buf: RustBuffer) throws -> SmbCloudSignupResult {
1240
- return try FfiConverterTypeSmbCloudSignupResult.lift(buf)
1241
-}
1242
-
1243
-#if swift(>=5.8)
1244
-@_documentation(visibility: private)
1245
-#endif
1246
-public func FfiConverterTypeSmbCloudSignupResult_lower(_ value: SmbCloudSignupResult) -> RustBuffer {
1247
- return FfiConverterTypeSmbCloudSignupResult.lower(value)
1248
-}
1249
-
1250
-
1251
-public struct SmbCloudTokenResponse {
1252
- public var accessToken: String
1253
- public var tokenType: String
1254
- public var expiresIn: Int32?
1255
- public var refreshToken: String?
1256
- public var scope: String?
1257
- public var idToken: String?
1258
-
1259
- // Default memberwise initializers are never public by default, so we
1260
- // declare one manually.
1261
- public init(accessToken: String, tokenType: String, expiresIn: Int32?, refreshToken: String?, scope: String?, idToken: String?) {
1262
- self.accessToken = accessToken
1263
- self.tokenType = tokenType
1264
- self.expiresIn = expiresIn
1265
- self.refreshToken = refreshToken
1266
- self.scope = scope
1267
- self.idToken = idToken
1268
- }
1269
-}
1270
-
1271
-#if compiler(>=6)
1272
-extension SmbCloudTokenResponse: Sendable {}
1273
-#endif
1274
-
1275
-
1276
-extension SmbCloudTokenResponse: Equatable, Hashable {
1277
- public static func ==(lhs: SmbCloudTokenResponse, rhs: SmbCloudTokenResponse) -> Bool {
1278
- if lhs.accessToken != rhs.accessToken {
1279
- return false
1280
- }
1281
- if lhs.tokenType != rhs.tokenType {
1282
- return false
1283
- }
1284
- if lhs.expiresIn != rhs.expiresIn {
1285
- return false
1286
- }
1287
- if lhs.refreshToken != rhs.refreshToken {
1288
- return false
1289
- }
1290
- if lhs.scope != rhs.scope {
1291
- return false
1292
- }
1293
- if lhs.idToken != rhs.idToken {
1294
- return false
1295
- }
1296
- return true
1297
- }
1298
-
1299
- public func hash(into hasher: inout Hasher) {
1300
- hasher.combine(accessToken)
1301
- hasher.combine(tokenType)
1302
- hasher.combine(expiresIn)
1303
- hasher.combine(refreshToken)
1304
- hasher.combine(scope)
1305
- hasher.combine(idToken)
1306
- }
1307
-}
1308
-
1309
-
1310
-
1311
-#if swift(>=5.8)
1312
-@_documentation(visibility: private)
1313
-#endif
1314
-public struct FfiConverterTypeSmbCloudTokenResponse: FfiConverterRustBuffer {
1315
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudTokenResponse {
1316
- return
1317
- try SmbCloudTokenResponse(
1318
- accessToken: FfiConverterString.read(from: &buf),
1319
- tokenType: FfiConverterString.read(from: &buf),
1320
- expiresIn: FfiConverterOptionInt32.read(from: &buf),
1321
- refreshToken: FfiConverterOptionString.read(from: &buf),
1322
- scope: FfiConverterOptionString.read(from: &buf),
1323
- idToken: FfiConverterOptionString.read(from: &buf)
1324
- )
1325
- }
1326
-
1327
- public static func write(_ value: SmbCloudTokenResponse, into buf: inout [UInt8]) {
1328
- FfiConverterString.write(value.accessToken, into: &buf)
1329
- FfiConverterString.write(value.tokenType, into: &buf)
1330
- FfiConverterOptionInt32.write(value.expiresIn, into: &buf)
1331
- FfiConverterOptionString.write(value.refreshToken, into: &buf)
1332
- FfiConverterOptionString.write(value.scope, into: &buf)
1333
- FfiConverterOptionString.write(value.idToken, into: &buf)
1334
- }
1335
-}
1336
-
1337
-
1338
-#if swift(>=5.8)
1339
-@_documentation(visibility: private)
1340
-#endif
1341
-public func FfiConverterTypeSmbCloudTokenResponse_lift(_ buf: RustBuffer) throws -> SmbCloudTokenResponse {
1342
- return try FfiConverterTypeSmbCloudTokenResponse.lift(buf)
1343
-}
1344
-
1345
-#if swift(>=5.8)
1346
-@_documentation(visibility: private)
1347
-#endif
1348
-public func FfiConverterTypeSmbCloudTokenResponse_lower(_ value: SmbCloudTokenResponse) -> RustBuffer {
1349
- return FfiConverterTypeSmbCloudTokenResponse.lower(value)
1350
-}
1351
-
1352
-
1353
-public struct SmbCloudUser {
1354
- public var id: Int32
1355
- public var email: String
1356
- public var createdAt: String
1357
- public var updatedAt: String
1358
-
1359
- // Default memberwise initializers are never public by default, so we
1360
- // declare one manually.
1361
- public init(id: Int32, email: String, createdAt: String, updatedAt: String) {
1362
- self.id = id
1363
- self.email = email
1364
- self.createdAt = createdAt
1365
- self.updatedAt = updatedAt
1366
- }
1367
-}
1368
-
1369
-#if compiler(>=6)
1370
-extension SmbCloudUser: Sendable {}
1371
-#endif
1372
-
1373
-
1374
-extension SmbCloudUser: Equatable, Hashable {
1375
- public static func ==(lhs: SmbCloudUser, rhs: SmbCloudUser) -> Bool {
1376
- if lhs.id != rhs.id {
1377
- return false
1378
- }
1379
- if lhs.email != rhs.email {
1380
- return false
1381
- }
1382
- if lhs.createdAt != rhs.createdAt {
1383
- return false
1384
- }
1385
- if lhs.updatedAt != rhs.updatedAt {
1386
- return false
1387
- }
1388
- return true
1389
- }
1390
-
1391
- public func hash(into hasher: inout Hasher) {
1392
- hasher.combine(id)
1393
- hasher.combine(email)
1394
- hasher.combine(createdAt)
1395
- hasher.combine(updatedAt)
1396
- }
1397
-}
1398
-
1399
-
1400
-
1401
-#if swift(>=5.8)
1402
-@_documentation(visibility: private)
1403
-#endif
1404
-public struct FfiConverterTypeSmbCloudUser: FfiConverterRustBuffer {
1405
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudUser {
1406
- return
1407
- try SmbCloudUser(
1408
- id: FfiConverterInt32.read(from: &buf),
1409
- email: FfiConverterString.read(from: &buf),
1410
- createdAt: FfiConverterString.read(from: &buf),
1411
- updatedAt: FfiConverterString.read(from: &buf)
1412
- )
1413
- }
1414
-
1415
- public static func write(_ value: SmbCloudUser, into buf: inout [UInt8]) {
1416
- FfiConverterInt32.write(value.id, into: &buf)
1417
- FfiConverterString.write(value.email, into: &buf)
1418
- FfiConverterString.write(value.createdAt, into: &buf)
1419
- FfiConverterString.write(value.updatedAt, into: &buf)
1420
- }
1421
-}
1422
-
1423
-
1424
-#if swift(>=5.8)
1425
-@_documentation(visibility: private)
1426
-#endif
1427
-public func FfiConverterTypeSmbCloudUser_lift(_ buf: RustBuffer) throws -> SmbCloudUser {
1428
- return try FfiConverterTypeSmbCloudUser.lift(buf)
1429
-}
1430
-
1431
-#if swift(>=5.8)
1432
-@_documentation(visibility: private)
1433
-#endif
1434
-public func FfiConverterTypeSmbCloudUser_lower(_ value: SmbCloudUser) -> RustBuffer {
1435
- return FfiConverterTypeSmbCloudUser.lower(value)
1436
-}
1437
-
1438
-
1439
-public struct SmbCloudUserInfo {
1440
- public var sub: String
1441
- public var email: String?
1442
- public var emailVerified: Bool?
1443
- public var tenantId: UInt64?
1444
- public var tenantSlug: String?
1445
-
1446
- // Default memberwise initializers are never public by default, so we
1447
- // declare one manually.
1448
- public init(sub: String, email: String?, emailVerified: Bool?, tenantId: UInt64?, tenantSlug: String?) {
1449
- self.sub = sub
1450
- self.email = email
1451
- self.emailVerified = emailVerified
1452
- self.tenantId = tenantId
1453
- self.tenantSlug = tenantSlug
1454
- }
1455
-}
1456
-
1457
-#if compiler(>=6)
1458
-extension SmbCloudUserInfo: Sendable {}
1459
-#endif
1460
-
1461
-
1462
-extension SmbCloudUserInfo: Equatable, Hashable {
1463
- public static func ==(lhs: SmbCloudUserInfo, rhs: SmbCloudUserInfo) -> Bool {
1464
- if lhs.sub != rhs.sub {
1465
- return false
1466
- }
1467
- if lhs.email != rhs.email {
1468
- return false
1469
- }
1470
- if lhs.emailVerified != rhs.emailVerified {
1471
- return false
1472
- }
1473
- if lhs.tenantId != rhs.tenantId {
1474
- return false
1475
- }
1476
- if lhs.tenantSlug != rhs.tenantSlug {
1477
- return false
1478
- }
1479
- return true
1480
- }
1481
-
1482
- public func hash(into hasher: inout Hasher) {
1483
- hasher.combine(sub)
1484
- hasher.combine(email)
1485
- hasher.combine(emailVerified)
1486
- hasher.combine(tenantId)
1487
- hasher.combine(tenantSlug)
1488
- }
1489
-}
1490
-
1491
-
1492
-
1493
-#if swift(>=5.8)
1494
-@_documentation(visibility: private)
1495
-#endif
1496
-public struct FfiConverterTypeSmbCloudUserInfo: FfiConverterRustBuffer {
1497
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudUserInfo {
1498
- return
1499
- try SmbCloudUserInfo(
1500
- sub: FfiConverterString.read(from: &buf),
1501
- email: FfiConverterOptionString.read(from: &buf),
1502
- emailVerified: FfiConverterOptionBool.read(from: &buf),
1503
- tenantId: FfiConverterOptionUInt64.read(from: &buf),
1504
- tenantSlug: FfiConverterOptionString.read(from: &buf)
1505
- )
1506
- }
1507
-
1508
- public static func write(_ value: SmbCloudUserInfo, into buf: inout [UInt8]) {
1509
- FfiConverterString.write(value.sub, into: &buf)
1510
- FfiConverterOptionString.write(value.email, into: &buf)
1511
- FfiConverterOptionBool.write(value.emailVerified, into: &buf)
1512
- FfiConverterOptionUInt64.write(value.tenantId, into: &buf)
1513
- FfiConverterOptionString.write(value.tenantSlug, into: &buf)
1514
- }
1515
-}
1516
-
1517
-
1518
-#if swift(>=5.8)
1519
-@_documentation(visibility: private)
1520
-#endif
1521
-public func FfiConverterTypeSmbCloudUserInfo_lift(_ buf: RustBuffer) throws -> SmbCloudUserInfo {
1522
- return try FfiConverterTypeSmbCloudUserInfo.lift(buf)
1523
-}
1524
-
1525
-#if swift(>=5.8)
1526
-@_documentation(visibility: private)
1527
-#endif
1528
-public func FfiConverterTypeSmbCloudUserInfo_lower(_ value: SmbCloudUserInfo) -> RustBuffer {
1529
- return FfiConverterTypeSmbCloudUserInfo.lower(value)
1530
-}
1531
-
1532
-// Note that we don't yet support `indirect` for enums.
1533
-// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
1534
-
1535
-public enum SmbCloudAccountStatus {
1536
-
1537
- case notFound
1538
- case ready(accessToken: String
1539
- )
1540
- case incomplete(errorCode: UInt32
1541
- )
1542
-}
1543
-
1544
-
1545
-#if compiler(>=6)
1546
-extension SmbCloudAccountStatus: Sendable {}
1547
-#endif
1548
-
1549
-#if swift(>=5.8)
1550
-@_documentation(visibility: private)
1551
-#endif
1552
-public struct FfiConverterTypeSmbCloudAccountStatus: FfiConverterRustBuffer {
1553
- typealias SwiftType = SmbCloudAccountStatus
1554
-
1555
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAccountStatus {
1556
- let variant: Int32 = try readInt(&buf)
1557
- switch variant {
1558
-
1559
- case 1: return .notFound
1560
-
1561
- case 2: return .ready(accessToken: try FfiConverterString.read(from: &buf)
1562
- )
1563
-
1564
- case 3: return .incomplete(errorCode: try FfiConverterUInt32.read(from: &buf)
1565
- )
1566
-
1567
- default: throw UniffiInternalError.unexpectedEnumCase
1568
- }
1569
- }
1570
-
1571
- public static func write(_ value: SmbCloudAccountStatus, into buf: inout [UInt8]) {
1572
- switch value {
1573
-
1574
-
1575
- case .notFound:
1576
- writeInt(&buf, Int32(1))
1577
-
1578
-
1579
- case let .ready(accessToken):
1580
- writeInt(&buf, Int32(2))
1581
- FfiConverterString.write(accessToken, into: &buf)
1582
-
1583
-
1584
- case let .incomplete(errorCode):
1585
- writeInt(&buf, Int32(3))
1586
- FfiConverterUInt32.write(errorCode, into: &buf)
1587
-
1588
- }
1589
- }
1590
-}
1591
-
1592
-
1593
-#if swift(>=5.8)
1594
-@_documentation(visibility: private)
1595
-#endif
1596
-public func FfiConverterTypeSmbCloudAccountStatus_lift(_ buf: RustBuffer) throws -> SmbCloudAccountStatus {
1597
- return try FfiConverterTypeSmbCloudAccountStatus.lift(buf)
1598
-}
1599
-
1600
-#if swift(>=5.8)
1601
-@_documentation(visibility: private)
1602
-#endif
1603
-public func FfiConverterTypeSmbCloudAccountStatus_lower(_ value: SmbCloudAccountStatus) -> RustBuffer {
1604
- return FfiConverterTypeSmbCloudAccountStatus.lower(value)
1605
-}
1606
-
1607
-
1608
-extension SmbCloudAccountStatus: Equatable, Hashable {}
1609
-
1610
-
1611
-
1612
-
1613
-
1614
-
1615
-
1616
-public enum SmbCloudAuthError: Swift.Error {
1617
-
1618
-
1619
-
1620
- case Api(errorCode: Int32, message: String
1621
- )
1622
-}
1623
-
1624
-
1625
-#if swift(>=5.8)
1626
-@_documentation(visibility: private)
1627
-#endif
1628
-public struct FfiConverterTypeSmbCloudAuthError: FfiConverterRustBuffer {
1629
- typealias SwiftType = SmbCloudAuthError
1630
-
1631
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudAuthError {
1632
- let variant: Int32 = try readInt(&buf)
1633
- switch variant {
1634
-
1635
-
1636
-
1637
-
1638
- case 1: return .Api(
1639
- errorCode: try FfiConverterInt32.read(from: &buf),
1640
- message: try FfiConverterString.read(from: &buf)
1641
- )
1642
-
1643
- default: throw UniffiInternalError.unexpectedEnumCase
1644
- }
1645
- }
1646
-
1647
- public static func write(_ value: SmbCloudAuthError, into buf: inout [UInt8]) {
1648
- switch value {
1649
-
1650
-
1651
-
1652
-
1653
-
1654
- case let .Api(errorCode,message):
1655
- writeInt(&buf, Int32(1))
1656
- FfiConverterInt32.write(errorCode, into: &buf)
1657
- FfiConverterString.write(message, into: &buf)
1658
-
1659
- }
1660
- }
1661
-}
1662
-
1663
-
1664
-#if swift(>=5.8)
1665
-@_documentation(visibility: private)
1666
-#endif
1667
-public func FfiConverterTypeSmbCloudAuthError_lift(_ buf: RustBuffer) throws -> SmbCloudAuthError {
1668
- return try FfiConverterTypeSmbCloudAuthError.lift(buf)
1669
-}
1670
-
1671
-#if swift(>=5.8)
1672
-@_documentation(visibility: private)
1673
-#endif
1674
-public func FfiConverterTypeSmbCloudAuthError_lower(_ value: SmbCloudAuthError) -> RustBuffer {
1675
- return FfiConverterTypeSmbCloudAuthError.lower(value)
1676
-}
1677
-
1678
-
1679
-extension SmbCloudAuthError: Equatable, Hashable {}
1680
-
1681
-
1682
-
1683
-
1684
-extension SmbCloudAuthError: Foundation.LocalizedError {
1685
- public var errorDescription: String? {
1686
- String(reflecting: self)
1687
- }
1688
-}
1689
-
1690
-
1691
-
1692
-
1693
-// Note that we don't yet support `indirect` for enums.
1694
-// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
1695
-
1696
-public enum SmbCloudEnvironment {
1697
-
1698
- case dev
1699
- case production
1700
-}
1701
-
1702
-
1703
-#if compiler(>=6)
1704
-extension SmbCloudEnvironment: Sendable {}
1705
-#endif
1706
-
1707
-#if swift(>=5.8)
1708
-@_documentation(visibility: private)
1709
-#endif
1710
-public struct FfiConverterTypeSmbCloudEnvironment: FfiConverterRustBuffer {
1711
- typealias SwiftType = SmbCloudEnvironment
1712
-
1713
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SmbCloudEnvironment {
1714
- let variant: Int32 = try readInt(&buf)
1715
- switch variant {
1716
-
1717
- case 1: return .dev
1718
-
1719
- case 2: return .production
1720
-
1721
- default: throw UniffiInternalError.unexpectedEnumCase
1722
- }
1723
- }
1724
-
1725
- public static func write(_ value: SmbCloudEnvironment, into buf: inout [UInt8]) {
1726
- switch value {
1727
-
1728
-
1729
- case .dev:
1730
- writeInt(&buf, Int32(1))
1731
-
1732
-
1733
- case .production:
1734
- writeInt(&buf, Int32(2))
1735
-
1736
- }
1737
- }
1738
-}
1739
-
1740
-
1741
-#if swift(>=5.8)
1742
-@_documentation(visibility: private)
1743
-#endif
1744
-public func FfiConverterTypeSmbCloudEnvironment_lift(_ buf: RustBuffer) throws -> SmbCloudEnvironment {
1745
- return try FfiConverterTypeSmbCloudEnvironment.lift(buf)
1746
-}
1747
-
1748
-#if swift(>=5.8)
1749
-@_documentation(visibility: private)
1750
-#endif
1751
-public func FfiConverterTypeSmbCloudEnvironment_lower(_ value: SmbCloudEnvironment) -> RustBuffer {
1752
- return FfiConverterTypeSmbCloudEnvironment.lower(value)
1753
-}
1754
-
1755
-
1756
-extension SmbCloudEnvironment: Equatable, Hashable {}
1757
-
1758
-
1759
-
1760
-
1761
-
1762
-
1763
-#if swift(>=5.8)
1764
-@_documentation(visibility: private)
1765
-#endif
1766
-fileprivate struct FfiConverterOptionInt32: FfiConverterRustBuffer {
1767
- typealias SwiftType = Int32?
1768
-
1769
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1770
- guard let value = value else {
1771
- writeInt(&buf, Int8(0))
1772
- return
1773
- }
1774
- writeInt(&buf, Int8(1))
1775
- FfiConverterInt32.write(value, into: &buf)
1776
- }
1777
-
1778
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1779
- switch try readInt(&buf) as Int8 {
1780
- case 0: return nil
1781
- case 1: return try FfiConverterInt32.read(from: &buf)
1782
- default: throw UniffiInternalError.unexpectedOptionalTag
1783
- }
1784
- }
1785
-}
1786
-
1787
-#if swift(>=5.8)
1788
-@_documentation(visibility: private)
1789
-#endif
1790
-fileprivate struct FfiConverterOptionUInt64: FfiConverterRustBuffer {
1791
- typealias SwiftType = UInt64?
1792
-
1793
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1794
- guard let value = value else {
1795
- writeInt(&buf, Int8(0))
1796
- return
1797
- }
1798
- writeInt(&buf, Int8(1))
1799
- FfiConverterUInt64.write(value, into: &buf)
1800
- }
1801
-
1802
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1803
- switch try readInt(&buf) as Int8 {
1804
- case 0: return nil
1805
- case 1: return try FfiConverterUInt64.read(from: &buf)
1806
- default: throw UniffiInternalError.unexpectedOptionalTag
1807
- }
1808
- }
1809
-}
1810
-
1811
-#if swift(>=5.8)
1812
-@_documentation(visibility: private)
1813
-#endif
1814
-fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer {
1815
- typealias SwiftType = Bool?
1816
-
1817
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1818
- guard let value = value else {
1819
- writeInt(&buf, Int8(0))
1820
- return
1821
- }
1822
- writeInt(&buf, Int8(1))
1823
- FfiConverterBool.write(value, into: &buf)
1824
- }
1825
-
1826
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1827
- switch try readInt(&buf) as Int8 {
1828
- case 0: return nil
1829
- case 1: return try FfiConverterBool.read(from: &buf)
1830
- default: throw UniffiInternalError.unexpectedOptionalTag
1831
- }
1832
- }
1833
-}
1834
-
1835
-#if swift(>=5.8)
1836
-@_documentation(visibility: private)
1837
-#endif
1838
-fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
1839
- typealias SwiftType = String?
1840
-
1841
- public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
1842
- guard let value = value else {
1843
- writeInt(&buf, Int8(0))
1844
- return
1845
- }
1846
- writeInt(&buf, Int8(1))
1847
- FfiConverterString.write(value, into: &buf)
1848
- }
1849
-
1850
- public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
1851
- switch try readInt(&buf) as Int8 {
1852
- case 0: return nil
1853
- case 1: return try FfiConverterString.read(from: &buf)
1854
- default: throw UniffiInternalError.unexpectedOptionalTag
1855
- }
1856
- }
1857
-}
1858
-private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
1859
-private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1
1860
-
1861
-fileprivate let uniffiContinuationHandleMap = UniffiHandleMap<UnsafeContinuation<Int8, Never>>()
1862
-
1863
-fileprivate func uniffiRustCallAsync<F, T>(
1864
- rustFutureFunc: () -> UInt64,
1865
- pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (),
1866
- completeFunc: (UInt64, UnsafeMutablePointer<RustCallStatus>) -> F,
1867
- freeFunc: (UInt64) -> (),
1868
- liftFunc: (F) throws -> T,
1869
- errorHandler: ((RustBuffer) throws -> Swift.Error)?
1870
-) async throws -> T {
1871
- // Make sure to call the ensure init function since future creation doesn't have a
1872
- // RustCallStatus param, so doesn't use makeRustCall()
1873
- uniffiEnsureSmbcloudAuthInitialized()
1874
- let rustFuture = rustFutureFunc()
1875
- defer {
1876
- freeFunc(rustFuture)
1877
- }
1878
- var pollResult: Int8;
1879
- repeat {
1880
- pollResult = await withUnsafeContinuation {
1881
- pollFunc(
1882
- rustFuture,
1883
- uniffiFutureContinuationCallback,
1884
- uniffiContinuationHandleMap.insert(obj: $0)
1885
- )
1886
- }
1887
- } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY
1888
-
1889
- return try liftFunc(makeRustCall(
1890
- { completeFunc(rustFuture, $0) },
1891
- errorHandler: errorHandler
1892
- ))
1893
-}
1894
-
1895
-// Callback handlers for an async calls. These are invoked by Rust when the future is ready. They
1896
-// lift the return value or error and resume the suspended function.
1897
-fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) {
1898
- if let continuation = try? uniffiContinuationHandleMap.remove(handle: handle) {
1899
- continuation.resume(returning: pollResult)
1900
- } else {
1901
- print("uniffiFutureContinuationCallback invalid handle")
1902
- }
1903
-}
1904
-
1905
-private enum InitializationResult {
1906
- case ok
1907
- case contractVersionMismatch
1908
- case apiChecksumMismatch
1909
-}
1910
-// Use a global variable to perform the versioning checks. Swift ensures that
1911
-// the code inside is only computed once.
1912
-private let initializationResult: InitializationResult = {
1913
- // Get the bindings contract version from our ComponentInterface
1914
- let bindings_contract_version = 29
1915
- // Get the scaffolding contract version by calling the into the dylib
1916
- let scaffolding_contract_version = ffi_smbcloud_auth_uniffi_contract_version()
1917
- if bindings_contract_version != scaffolding_contract_version {
1918
- return InitializationResult.contractVersionMismatch
1919
- }
1920
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_build_apple_authorization_request() != 20401) {
1921
- return InitializationResult.apiChecksumMismatch
1922
- }
1923
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_build_oidc_authorization_request() != 27410) {
1924
- return InitializationResult.apiChecksumMismatch
1925
- }
1926
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_exchange_oidc_code() != 62992) {
1927
- return InitializationResult.apiChecksumMismatch
1928
- }
1929
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_get_oidc_userinfo() != 55608) {
1930
- return InitializationResult.apiChecksumMismatch
1931
- }
1932
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_login() != 22565) {
1933
- return InitializationResult.apiChecksumMismatch
1934
- }
1935
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_logout() != 50854) {
1936
- return InitializationResult.apiChecksumMismatch
1937
- }
1938
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_me() != 14252) {
1939
- return InitializationResult.apiChecksumMismatch
1940
- }
1941
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_parse_apple_callback_url() != 36073) {
1942
- return InitializationResult.apiChecksumMismatch
1943
- }
1944
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_parse_oidc_callback_url() != 50343) {
1945
- return InitializationResult.apiChecksumMismatch
1946
- }
1947
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_remove_account() != 59938) {
1948
- return InitializationResult.apiChecksumMismatch
1949
- }
1950
- if (uniffi_smbcloud_auth_checksum_method_smbcloudauth_signup() != 1373) {
1951
- return InitializationResult.apiChecksumMismatch
1952
- }
1953
- if (uniffi_smbcloud_auth_checksum_constructor_smbcloudauth_new() != 47975) {
1954
- return InitializationResult.apiChecksumMismatch
1955
- }
1956
-
1957
- return InitializationResult.ok
1958
-}()
1959
-
1960
-// Make the ensure init function public so that other modules which have external type references to
1961
-// our types can call it.
1962
-public func uniffiEnsureSmbcloudAuthInitialized() {
1963
- switch initializationResult {
1964
- case .ok:
1965
- break
1966
- case .contractVersionMismatch:
1967
- fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
1968
- case .apiChecksumMismatch:
1969
- fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1970
- }
1971
-}
1972
-
1973
-// swiftlint:enable all
\ No newline at end of file