diff --git a/ios/AppDelegate.swift b/ios/AppDelegate.swift new file mode 100644 index 0000000000..db9972b5ed --- /dev/null +++ b/ios/AppDelegate.swift @@ -0,0 +1,137 @@ +// Copyright (c) 2024 Proton Technologies AG +// +// This file is part of Proton Mail. +// +// Proton Mail is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail. If not, see https://www.gnu.org/licenses/. + +import SwiftUI + +final class AppDelegate: NSObject, UIApplicationDelegate { + private let appDelegateManager = AppDelegateWrapper() + + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil + ) -> Bool { + return appDelegateManager.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} + +import proton_mail_uniffi + +struct AppDelegateWrapper { + private let dependencies: Dependencies + + init(dependencies: Dependencies = .init()) { + self.dependencies = dependencies + } + + func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? + ) -> Bool { + do { + try dependencies.appContext.start() + + return true + + } catch { + print("❌ error launching the app \(error)") + return false + } + } +} + +extension AppDelegateWrapper { + + struct Dependencies { + let appContext: AppContext = .shared + } +} + + +//final class AppContext { +// let appSession: AppSession +// +// init() throws { +// self.appSession = try AppSession() +// } +//} + + + +class Dummy { + + func start(email: String, password: String) async throws { + print("email: \(email)") + guard let applicationSupport = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { + throw AppSessionError.applicationSupportDirectoryNotAccessible + } + + let applicationSupportPath = applicationSupport.path() + + // TODO: exclude application support from iCloud backup + + let mailContext = try MailContext( + sessionDir: applicationSupportPath, + userDir: applicationSupportPath, + logDir: applicationSupportPath, + logDebug: true, + keyChain: Keychain.shared, + networkCallback: NetworkStatusManager.shared + ) + + let flow = try mailContext.newLoginFlow(cb: SessionDelegate.shared) + try await flow.login(email: email, password: password) + + // .isAwaiting2fa has a bug + // if flow.isAwaiting2fa() { + // print("❌ WAITING 2FA!") + // try await flow.submitTotp(code: "") + // } + + // if flow.isLoggedIn() { + // let userContext = try flow.toUserContext() // flow object can now be discarded. + // } + + // For an existing session + let sessions = try mailContext.storedSessions() + + guard let activeSession = sessions.first else { + print("❌ No active session") + return + } + let userContext = try mailContext.userContextFromSession(session: activeSession, cb: SessionDelegate.shared) + + try await userContext.initialize(cb: UserContextInitializationDelegate.shared) + let mailbox = try Mailbox(ctx: userContext) + let conversations = try mailbox.conversations(count: 50) + + print(conversations) + } + +} + + +enum AppSessionError: Error { + case applicationSupportDirectoryNotAccessible +} + +enum Keys: String { + case session +} + + + + diff --git a/ios/ProtonMailApp.swift b/ios/ProtonMailApp.swift index 68d2fcf398..253e070e44 100644 --- a/ios/ProtonMailApp.swift +++ b/ios/ProtonMailApp.swift @@ -20,14 +20,15 @@ import DesignSystem @main struct ProtonMail: App { - let appState = AppState() + @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate + let appUIState = AppUIState(isSidebarOpen: false) let userSettings = UserSettings(mailboxViewMode: .conversation) var body: some Scene { WindowGroup { Root() - .environmentObject(appState) + .environmentObject(AppContext.shared.appState) .environmentObject(appUIState) .environmentObject(userSettings) } diff --git a/ios/Resources/PreviewData.swift b/ios/Resources/PreviewData.swift index 43c493e216..e116b4e9f1 100644 --- a/ios/Resources/PreviewData.swift +++ b/ios/Resources/PreviewData.swift @@ -30,7 +30,7 @@ enum PreviewData { .init(id: UUID().uuidString, name: "Settings", icon: DS.Icon.icCogWheel, badge: "", route: .settings), ]) - static var mailboxConversationScreenModel: MailboxConversationScreenModel { + static var mailboxConversations: [MailboxConversationCellUIModel] { let conversations: [MailboxConversationCellUIModel] = (1..<100).map { value in let randomSenderSubject = randomSenderSubject() @@ -50,7 +50,7 @@ enum PreviewData { expirationDate: expirationDate ? .init(text: "Expires in < 5 minutes", color: DS.Color.notificationError) : .init(text: "", color: .clear) ) } - return .init(conversations: conversations) + return conversations } static let mailboxLabels: [MailboxLabelUIModel] = [ diff --git a/ios/State/AppContext.swift b/ios/State/AppContext.swift new file mode 100644 index 0000000000..f0346613f7 --- /dev/null +++ b/ios/State/AppContext.swift @@ -0,0 +1,172 @@ +// Copyright (c) 2024 Proton Technologies AG +// +// This file is part of Proton Mail. +// +// Proton Mail is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail. If not, see https://www.gnu.org/licenses/. + +import Foundation +import proton_mail_uniffi + +protocol AppContextService { + + init(dependencies: AppContext.Dependencies) + func start() async throws + func loginFlow() throws -> LoginFlow + func userContextForActiveSession() async throws -> MailUserContext? +} + +final class AppContext: AppContextService { + static let shared: AppContext = .init() + + private var _mailContext: MailContext! + private let dependencies: AppContext.Dependencies + + private var mailContext: MailContext { + guard let mailContext = _mailContext else { + fatalError("AppSession.start was not called") + } + return mailContext + } + + private (set) var appState: AppState + + var activeSession: StoredSession? { + do { + return try mailContext.storedSessions().first + } catch { + print("❌ mailContext.storedSessions error: \(error)") + return nil + } + } + + init(dependencies: Dependencies = .init()) { + self.dependencies = dependencies + self.appState = AppState() + } + + func start() throws { + guard let applicationSupport = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { + throw AppSessionError.applicationSupportDirectoryNotAccessible + } + + // TODO: exclude application support from iCloud backup + + let applicationSupportPath = applicationSupport.path() + _mailContext = try MailContext( + sessionDir: applicationSupportPath, + userDir: applicationSupportPath, + logDir: applicationSupportPath, + logDebug: true, + keyChain: dependencies.keychain, + networkCallback: dependencies.networkStatus + ) + + appState.appContext = self + Task { + await refreshAppState() + } + } + + func removeSession() async { + try? dependencies.keychain.delete() + await refreshAppState() + } + + func loginFlow() throws -> LoginFlow { + try mailContext.newLoginFlow(cb: SessionDelegate.shared) + } + + func userContextForActiveSession() async throws -> MailUserContext? { + guard let activeSession else { return nil } + let userContext = try mailContext.userContextFromSession(session: activeSession, cb: SessionDelegate.shared) + try await userContext.initialize(cb: UserContextInitializationDelegate.shared) + return userContext + } + + func refreshAppState() async { + await appState.refresh() + } +} + +extension AppContext { + + struct Dependencies { + let fileManager: FileManager = .default + let keychain: OsKeyChain = Keychain.shared + let networkStatus: NetworkStatusChanged = NetworkStatusManager.shared + } +} + +final class Keychain: OsKeyChain { + static let shared = Keychain() + + // TODO: use the keychain + + func store(key: String) throws { + print("KeychainWrapper.store key:\(key)") + UserDefaults.standard.setValue(key, forKey: Keys.session.rawValue) + } + + func delete() throws { + let existingKey: String = (try? get()) ?? "" + print("KeychainWrapper.delete, existing value: \(existingKey)") + UserDefaults.standard.removeObject(forKey: Keys.session.rawValue) + } + + func get() throws -> String? { + let value = UserDefaults.standard.string(forKey: Keys.session.rawValue) + print("KeychainWrapper.get \(value ?? "-")") + return value + } +} + +final class NetworkStatusManager: NetworkStatusChanged { + static let shared = NetworkStatusManager() + + func onNetworkStatusChanged(online: Bool) { + print("onNetworkStatusChanged online: \(online)") + } +} + +final class SessionDelegate: SessionCallback { + static let shared = SessionDelegate() + + func onSessionRefresh() { + print("onSessionRefresh") + } + + func onSessionDeleted() { + print("onSessionDeleted") + } + + func onRefreshFailed(e: proton_mail_uniffi.SessionError) { + print("onRefreshFailed error: \(e)") + } + + func onError(err: proton_mail_uniffi.SessionError) { + print("onError error: \(err)") + } +} + +final class UserContextInitializationDelegate: MailUserContextInitializationCallback { + static let shared = UserContextInitializationDelegate() + + func onStage(stage: proton_mail_uniffi.MailUserContextInitializationStage) { + print("UserContextInitializationDelegate.onStage stage: \(stage)") + } + + func onStageErr(stage: proton_mail_uniffi.MailUserContextInitializationStage, err: proton_mail_uniffi.MailContextError) { + print("UserContextInitializationDelegate.onStageError stage: \(stage) error: \(err)") + } +} diff --git a/ios/State/AppState.swift b/ios/State/AppState.swift index eda02fa4a4..aef56222a3 100644 --- a/ios/State/AppState.swift +++ b/ios/State/AppState.swift @@ -16,23 +16,26 @@ // along with Proton Mail. If not, see https://www.gnu.org/licenses/. import Foundation +import proton_mail_uniffi final class AppState: ObservableObject { - @Published private (set) var activeSession: MailSession? + @Published private (set) var activeSession: Bool = false + + weak var appContext: AppContext? var hasAuthenticatedSession: Bool { - activeSession != nil + appContext?.activeSession != nil } - func addActiveSession(_ session: MailSession) { - activeSession = session + @MainActor + func refresh() { + activeSession = hasAuthenticatedSession } - func removeSession() { - activeSession = nil + func removeActiveSession() { + guard let appContext else { return } + Task { + await appContext.removeSession() + } } } - -struct MailSession { - -} diff --git a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationCell.swift b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationCell.swift index 516ce043f8..67481c9ffd 100644 --- a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationCell.swift +++ b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationCell.swift @@ -34,7 +34,7 @@ struct MailboxConversationCell: View { HStack(spacing: 16.0) { AvatarCheckboxView( - isSelected: uiModel.isSelected, + isSelected: uiModel.isSelected.value, avatar: uiModel.avatar, onDidChangeSelection: { onEvent(.onSelectedChange(isSelected: $0)) } ) @@ -94,12 +94,12 @@ struct MailboxConversationCell: View { } } .padding(14) - .background(uiModel.isSelected ? DS.Color.backgroundSecondary : Color(UIColor.systemBackground)) + .background(uiModel.isSelected.value ? DS.Color.backgroundSecondary : Color(UIColor.systemBackground)) } } @Observable -final class MailboxConversationCellUIModel: Identifiable { +final class MailboxConversationCellUIModel: Identifiable, Sendable { let id: String let avatar: AvatarUIModel let senders: String @@ -108,7 +108,7 @@ final class MailboxConversationCellUIModel: Identifiable { let isRead: Bool let isStarred: Bool - var isSelected: Bool = false + let isSelected = SendableBool(false) let isSenderProtonOfficial: Bool let numMessages: Int @@ -169,7 +169,7 @@ enum MailboxConversationCellEvent { ) } let model1 = model - model1.isSelected = true + model1.isSelected.set(true) return VStack { diff --git a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreen.swift b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreen.swift index 49e2e28aba..eec75239cb 100644 --- a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreen.swift +++ b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreen.swift @@ -22,40 +22,60 @@ struct MailboxConversationScreen: View { @State var model: MailboxConversationScreenModel var body: some View { - List { - ForEach(model.conversations) { conversation in - MailboxConversationCell( - uiModel: conversation, - onEvent: { [weak model] event in - switch event { - case .onSelectedChange(let isSelected): - model?.onConversationSelectionChange(id: conversation.id, isSelected: isSelected) - case .onStarredChange(let isStarred): - model?.onConversationStarChange(id: conversation.id, isStarred: isStarred) - case .onAttachmentTap(let attachmentId): - model?.onAttachmentTap(attachmentId: attachmentId) - } + ZStack { + switch model.state { + case .loading: + VStack { + Spacer() + ProgressView() + Spacer() + } + case .empty: + VStack { + Text("No conversations") + } + case .data(let conversations): + List { + ForEach(conversations) { conversation in + MailboxConversationCell( + uiModel: conversation, + onEvent: { [weak model] event in + switch event { + case .onSelectedChange(let isSelected): + model?.onConversationSelectionChange(id: conversation.id, isSelected: isSelected) + case .onStarredChange(let isStarred): + model?.onConversationStarChange(id: conversation.id, isStarred: isStarred) + case .onAttachmentTap(let attachmentId): + model?.onAttachmentTap(attachmentId: attachmentId) + } + } + ) + .listRowInsets( + .init(top: 1, leading: 1, bottom: 1, trailing: 0) + ) + .listRowSeparator(.hidden) + .compositingGroup() + .clipShape( + .rect( + topLeadingRadius: 20, + bottomLeadingRadius: 20, + bottomTrailingRadius: 0, + topTrailingRadius: 0 + ) + ) } - ) - .listRowInsets( - .init(top: 1, leading: 1, bottom: 1, trailing: 0) - ) - .listRowSeparator(.hidden) - .compositingGroup() - .clipShape( - .rect( - topLeadingRadius: 20, - bottomLeadingRadius: 20, - bottomTrailingRadius: 0, - topTrailingRadius: 0 - ) - ) + } + .listStyle(.plain) + } + } + .onAppear { + Task { + await model.fecthConversations() } } - .listStyle(.plain) } } #Preview { - return MailboxConversationScreen(model: PreviewData.mailboxConversationScreenModel) + return MailboxConversationScreen(model: .init(conversations: PreviewData.mailboxConversations)) } diff --git a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreenModel.swift b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreenModel.swift index b3857f2955..1c1cc0fc0e 100644 --- a/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreenModel.swift +++ b/ios/UI/Screens/Mailbox/MailboxConversationScreen/MailboxConversationScreenModel.swift @@ -17,15 +17,74 @@ import Foundation import struct SwiftUI.Color +import proton_mail_uniffi -typealias ConversationId = String +enum MailboxConversationScreenState: Sendable { + case loading + case empty + case data([MailboxConversationCellUIModel]) + + var isEmpty: Bool { + switch self { + case .empty: return true + case .loading, .data: return false + } + } + + var isLoading: Bool { + switch self { + case .loading: return true + case .empty, .data: return false + } + } + + var conversations: [MailboxConversationCellUIModel] { + switch self { + case .data(let conversations): return conversations + case .empty, .loading: return [] + } + } +} @Observable final class MailboxConversationScreenModel { - private(set) var conversations: [MailboxConversationCellUIModel] + private let dependencies: Dependencies + private(set) var state: MailboxConversationScreenState = .loading - init(conversations: [MailboxConversationCellUIModel]) { - self.conversations = conversations + var conversations: [MailboxConversationCellUIModel] { + state.conversations + } + + var isLoading: Bool { + state.isLoading + } + + var isEmpty: Bool { + state.isEmpty + } + + init(conversations: [MailboxConversationCellUIModel] = [], dependencies: Dependencies = .init()) { + self.state = conversations.isEmpty ? .empty : .data(conversations) + self.dependencies = dependencies + } + + func fecthConversations() async { + do { + await updateState(.loading) + guard let userContext = try await dependencies.appContext.userContextForActiveSession() else { + return + } + let mailbox = try Mailbox(ctx: userContext) + let conversations = try mailbox.conversations(count: 50) + await updateState(.data(conversations.map { $0.toMailboxConversationCellUIModel() })) + } catch { + print("❌ fetchConversations error: \(error)") + } + } + + @MainActor + private func updateState(_ state: MailboxConversationScreenState) { + self.state = state } @MainActor @@ -33,7 +92,7 @@ final class MailboxConversationScreenModel { guard let index = conversations.firstIndex(where: { $0.id == id }) else { return } - conversations[index].isSelected = isSelected + conversations[index].isSelected.set(isSelected) } func onConversationStarChange(id: String, isStarred: Bool) { @@ -47,3 +106,62 @@ final class MailboxConversationScreenModel { print("Attachment tapped \(attachmentId)") } } + +extension MailboxConversationScreenModel { + + struct Dependencies { + let appContext: AppContext = .shared + } +} + +extension LocalConversation { + + var initials: String { + (senders.first?.senderName.prefix(2) ?? "P").uppercased() + } + + func toLabel() -> MailboxLabelUIModel { + guard + let labels = self.labels, + let firstLabel = labels.first + else { return .init() } + return .init( + id: String(firstLabel.id), + color: Color(hex: firstLabel.color), + text: firstLabel.name, + numExtraLabels: labels.count + ) + } + + func toMailboxConversationCellUIModel() -> MailboxConversationCellUIModel { + .init( + id: remoteId ?? String(id), + avatar: .init(initials: initials), + senders: senders.map(\.senderName).joined(separator: ", "), + subject: subject, + date: Date(timeIntervalSince1970: TimeInterval(time)), + isRead: numUnread == 0, + isStarred: false, // TODO: + isSenderProtonOfficial: senders.first?.isProton.isTrue ?? false, + numMessages: numMessages > 1 ? Int(numMessages) : 0, + labelUIModel: toLabel(), + expirationDate: .init(text: "", color: .black) + ) + } +} + +extension MessageAddress { + + var senderName: String { + !name.isEmpty ? name : address + } +} + +extension ProtonBoolean { + var isTrue: Bool { + switch self { + case .true: return true + case .false: return false + } + } +} diff --git a/ios/UI/Screens/Mailbox/MailboxScreen.swift b/ios/UI/Screens/Mailbox/MailboxScreen.swift index b4578cf196..25d8cb7b0d 100644 --- a/ios/UI/Screens/Mailbox/MailboxScreen.swift +++ b/ios/UI/Screens/Mailbox/MailboxScreen.swift @@ -26,7 +26,7 @@ struct MailboxScreen: View { NavigationStack { ZStack { if userSettings.mailboxViewMode == .conversation { - MailboxConversationScreen(model: PreviewData.mailboxConversationScreenModel) + MailboxConversationScreen(model: .init()) } else { Text("message list mailbox") } diff --git a/ios/UI/Screens/Mailbox/MailboxToolbar.swift b/ios/UI/Screens/Mailbox/MailboxToolbar.swift index dc0f289b08..20cfeff711 100644 --- a/ios/UI/Screens/Mailbox/MailboxToolbar.swift +++ b/ios/UI/Screens/Mailbox/MailboxToolbar.swift @@ -34,7 +34,7 @@ struct MailboxToolbar: ViewModifier { } ToolbarItem(placement: .navigationBarTrailing) { Button(action: { - appState.removeSession() + appState.removeActiveSession() }, label: { Text("sign out") .font(.footnote) diff --git a/ios/UI/Screens/SignIn/SignInScreen.swift b/ios/UI/Screens/SignIn/SignInScreen.swift index 9b1369f826..c7d6d20a81 100644 --- a/ios/UI/Screens/SignIn/SignInScreen.swift +++ b/ios/UI/Screens/SignIn/SignInScreen.swift @@ -24,6 +24,8 @@ struct SignIn: View { @State private var email: String = "" @State private var password: String = "" + private let screenModel: SignInScreenModel = .init() + var body: some View { VStack(spacing: 28) { Spacer() @@ -39,6 +41,8 @@ struct SignIn: View { .frame(height: 44) .padding(.horizontal, 12) .background(Color.white) + .textInputAutocapitalization(.never) + .keyboardType(.emailAddress) } VStack(alignment: .leading, spacing: 11) { @@ -54,18 +58,32 @@ struct SignIn: View { .background(Color.white) } - Button { - hideKeyboard() - print("\(email) \(password)") - appState.addActiveSession(MailSession()) - } label: { - Text("Sign In") - .foregroundColor(.white) - .frame(width: 215, height: 44, alignment: .center) + if screenModel.isLoading { + + HStack { + Spacer() + ProgressView() + Spacer() + } + } else { + + Button { + hideKeyboard() + screenModel.login(email: email, password: password) + } label: { + Text("Sign In") + .foregroundColor(.white) + .frame(width: 215, height: 44, alignment: .center) + } + .background(.secondary) + .cornerRadius(4) + .padding(.top, 36) + .alert(screenModel.errorMessage, isPresented: screenModel.isErrorPresented) { + Button("OK") { + screenModel.showError = false + } + } } - .background(.secondary) - .cornerRadius(4) - .padding(.top, 36) Spacer() } diff --git a/ios/UI/Screens/SignIn/SignInScreenModel.swift b/ios/UI/Screens/SignIn/SignInScreenModel.swift new file mode 100644 index 0000000000..22d8d3193d --- /dev/null +++ b/ios/UI/Screens/SignIn/SignInScreenModel.swift @@ -0,0 +1,66 @@ +// Copyright (c) 2024 Proton Technologies AG +// +// This file is part of Proton Mail. +// +// Proton Mail is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail. If not, see https://www.gnu.org/licenses/. + +import proton_mail_uniffi +import SwiftUI + +@Observable +final class SignInScreenModel: Sendable { + private let dependencies: Dependencies + private(set) var isLoading = false + private(set) var errorMessage: String = "" { + didSet { + showError = !errorMessage.isEmpty + } + } + var showError: Bool = false + + var isErrorPresented: Binding { + Binding(get: { + self.showError + }, set: { + self.showError = $0 + }) + } + + init(dependencies: Dependencies = .init()) { + self.dependencies = dependencies + } + + func login(email: String, password: String) { + Task { + isLoading = true + let flow = try dependencies.appContext.loginFlow() + do { + try await flow.login(email: email, password: password) + await dependencies.appContext.refreshAppState() + } catch { + errorMessage = error.localizedDescription + } + isLoading = false + } + } +} + +extension SignInScreenModel { + + struct Dependencies: Sendable { + let appContext: AppContext = .shared + } +} + +extension AppContext: @unchecked Sendable {} diff --git a/ios/Utils/SwiftUI/Selectable.swift b/ios/Utils/SwiftUI/Selectable.swift new file mode 100644 index 0000000000..91efdb13be --- /dev/null +++ b/ios/Utils/SwiftUI/Selectable.swift @@ -0,0 +1,39 @@ +// Copyright (c) 2024 Proton Technologies AG +// +// This file is part of Proton Mail. +// +// Proton Mail is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Proton Mail is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Proton Mail. If not, see https://www.gnu.org/licenses/. + +import Foundation + +/** + Bolean representation for Sendable objects that need mutation. + + A common example would be a UI cell model that needs to be selected. + + Notice that @unchecked Sendable is ensured by the @MainActor annotation in the setter function + */ +@Observable +final class SendableBool: @unchecked Sendable { + private(set) var value: Bool + + init(_ value: Bool) { + self.value = value + } + + @MainActor + func set(_ value: Bool) { + self.value = value + } +} diff --git a/localPackages/proton_mail_uniffi/Package.swift b/localPackages/proton_mail_uniffi/Package.swift new file mode 100644 index 0000000000..fd9fe7a06f --- /dev/null +++ b/localPackages/proton_mail_uniffi/Package.swift @@ -0,0 +1,32 @@ +// swift-tools-version:5.5 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "proton_mail_uniffi", + platforms: [ + .iOS(.v15), + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .library( + name: "proton_mail_uniffi", + targets: ["proton_mail_uniffi", "proton_mail_uniffi_ffi"] + ), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + // .package(url: /* package url */, from: "1.0.0"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .target( + name: "proton_mail_uniffi", + dependencies: ["proton_mail_uniffi_ffi"] + ), + .binaryTarget(name: "proton_mail_uniffi_ffi", path: "Sources/proton_mail_uniffi_ffi.xcframework"), + ] +) + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_core.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_core.swift new file mode 100644 index 0000000000..91a33ded57 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_core.swift @@ -0,0 +1,1186 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_api_core_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_api_core_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + +public struct Dummy { + public var userId: UserId + public var uid: Uid + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + userId: UserId, + uid: Uid) { + self.userId = userId + self.uid = uid + } +} + + +extension Dummy: Equatable, Hashable { + public static func ==(lhs: Dummy, rhs: Dummy) -> Bool { + if lhs.userId != rhs.userId { + return false + } + if lhs.uid != rhs.uid { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(userId) + hasher.combine(uid) + } +} + + +public struct FfiConverterTypeDummy: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Dummy { + return + try Dummy( + userId: FfiConverterTypeUserId.read(from: &buf), + uid: FfiConverterTypeUid.read(from: &buf) + ) + } + + public static func write(_ value: Dummy, into buf: inout [UInt8]) { + FfiConverterTypeUserId.write(value.userId, into: &buf) + FfiConverterTypeUid.write(value.uid, into: &buf) + } +} + + +public func FfiConverterTypeDummy_lift(_ buf: RustBuffer) throws -> Dummy { + return try FfiConverterTypeDummy.lift(buf) +} + +public func FfiConverterTypeDummy_lower(_ value: Dummy) -> RustBuffer { + return FfiConverterTypeDummy.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +/** + * Errors that may occur during an HTTP request, mostly related to network. + */ +public enum HttpRequestError { + + case api + case redirect + case timeout + case connection + case request + case encodeOrDecode + case other +} + +public struct FfiConverterTypeHttpRequestError: FfiConverterRustBuffer { + typealias SwiftType = HttpRequestError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> HttpRequestError { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .api + + case 2: return .redirect + + case 3: return .timeout + + case 4: return .connection + + case 5: return .request + + case 6: return .encodeOrDecode + + case 7: return .other + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: HttpRequestError, into buf: inout [UInt8]) { + switch value { + + + case .api: + writeInt(&buf, Int32(1)) + + + case .redirect: + writeInt(&buf, Int32(2)) + + + case .timeout: + writeInt(&buf, Int32(3)) + + + case .connection: + writeInt(&buf, Int32(4)) + + + case .request: + writeInt(&buf, Int32(5)) + + + case .encodeOrDecode: + writeInt(&buf, Int32(6)) + + + case .other: + writeInt(&buf, Int32(7)) + + } + } +} + + +public func FfiConverterTypeHttpRequestError_lift(_ buf: RustBuffer) throws -> HttpRequestError { + return try FfiConverterTypeHttpRequestError.lift(buf) +} + +public func FfiConverterTypeHttpRequestError_lower(_ value: HttpRequestError) -> RustBuffer { + return FfiConverterTypeHttpRequestError.lower(value) +} + + +extension HttpRequestError: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum ProtonBoolean { + + case `false` + case `true` +} + +public struct FfiConverterTypeProtonBoolean: FfiConverterRustBuffer { + typealias SwiftType = ProtonBoolean + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProtonBoolean { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .`false` + + case 2: return .`true` + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: ProtonBoolean, into buf: inout [UInt8]) { + switch value { + + + case .`false`: + writeInt(&buf, Int32(1)) + + + case .`true`: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeProtonBoolean_lift(_ buf: RustBuffer) throws -> ProtonBoolean { + return try FfiConverterTypeProtonBoolean.lift(buf) +} + +public func FfiConverterTypeProtonBoolean_lower(_ value: ProtonBoolean) -> RustBuffer { + return FfiConverterTypeProtonBoolean.lower(value) +} + + +extension ProtonBoolean: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum TfaStatus { + + case none + case totp + case fido2 + case totpOrFido2 +} + +public struct FfiConverterTypeTFAStatus: FfiConverterRustBuffer { + typealias SwiftType = TfaStatus + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TfaStatus { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .none + + case 2: return .totp + + case 3: return .fido2 + + case 4: return .totpOrFido2 + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: TfaStatus, into buf: inout [UInt8]) { + switch value { + + + case .none: + writeInt(&buf, Int32(1)) + + + case .totp: + writeInt(&buf, Int32(2)) + + + case .fido2: + writeInt(&buf, Int32(3)) + + + case .totpOrFido2: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeTFAStatus_lift(_ buf: RustBuffer) throws -> TfaStatus { + return try FfiConverterTypeTFAStatus.lift(buf) +} + +public func FfiConverterTypeTFAStatus_lower(_ value: TfaStatus) -> RustBuffer { + return FfiConverterTypeTFAStatus.lower(value) +} + + +extension TfaStatus: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserLogAuth { + + case disabled + case basic + case advanced +} + +public struct FfiConverterTypeUserLogAuth: FfiConverterRustBuffer { + typealias SwiftType = UserLogAuth + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserLogAuth { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .disabled + + case 2: return .basic + + case 3: return .advanced + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserLogAuth, into buf: inout [UInt8]) { + switch value { + + + case .disabled: + writeInt(&buf, Int32(1)) + + + case .basic: + writeInt(&buf, Int32(2)) + + + case .advanced: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeUserLogAuth_lift(_ buf: RustBuffer) throws -> UserLogAuth { + return try FfiConverterTypeUserLogAuth.lift(buf) +} + +public func FfiConverterTypeUserLogAuth_lower(_ value: UserLogAuth) -> RustBuffer { + return FfiConverterTypeUserLogAuth.lower(value) +} + + +extension UserLogAuth: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserMnemonicStatus { + + case disabled + case enabledButNotSet + case enabledNeedsReActivation + case enabledAndSet + case unknown +} + +public struct FfiConverterTypeUserMnemonicStatus: FfiConverterRustBuffer { + typealias SwiftType = UserMnemonicStatus + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserMnemonicStatus { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .disabled + + case 2: return .enabledButNotSet + + case 3: return .enabledNeedsReActivation + + case 4: return .enabledAndSet + + case 5: return .unknown + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserMnemonicStatus, into buf: inout [UInt8]) { + switch value { + + + case .disabled: + writeInt(&buf, Int32(1)) + + + case .enabledButNotSet: + writeInt(&buf, Int32(2)) + + + case .enabledNeedsReActivation: + writeInt(&buf, Int32(3)) + + + case .enabledAndSet: + writeInt(&buf, Int32(4)) + + + case .unknown: + writeInt(&buf, Int32(5)) + + } + } +} + + +public func FfiConverterTypeUserMnemonicStatus_lift(_ buf: RustBuffer) throws -> UserMnemonicStatus { + return try FfiConverterTypeUserMnemonicStatus.lift(buf) +} + +public func FfiConverterTypeUserMnemonicStatus_lower(_ value: UserMnemonicStatus) -> RustBuffer { + return FfiConverterTypeUserMnemonicStatus.lower(value) +} + + +extension UserMnemonicStatus: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserSettingsDateFormat { + + case `default` + case ddmmyyyy + case mmddyyyy + case yyyymmdd +} + +public struct FfiConverterTypeUserSettingsDateFormat: FfiConverterRustBuffer { + typealias SwiftType = UserSettingsDateFormat + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserSettingsDateFormat { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .`default` + + case 2: return .ddmmyyyy + + case 3: return .mmddyyyy + + case 4: return .yyyymmdd + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserSettingsDateFormat, into buf: inout [UInt8]) { + switch value { + + + case .`default`: + writeInt(&buf, Int32(1)) + + + case .ddmmyyyy: + writeInt(&buf, Int32(2)) + + + case .mmddyyyy: + writeInt(&buf, Int32(3)) + + + case .yyyymmdd: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeUserSettingsDateFormat_lift(_ buf: RustBuffer) throws -> UserSettingsDateFormat { + return try FfiConverterTypeUserSettingsDateFormat.lift(buf) +} + +public func FfiConverterTypeUserSettingsDateFormat_lower(_ value: UserSettingsDateFormat) -> RustBuffer { + return FfiConverterTypeUserSettingsDateFormat.lower(value) +} + + +extension UserSettingsDateFormat: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserSettingsDensity { + + case comfortable + case compact +} + +public struct FfiConverterTypeUserSettingsDensity: FfiConverterRustBuffer { + typealias SwiftType = UserSettingsDensity + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserSettingsDensity { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .comfortable + + case 2: return .compact + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserSettingsDensity, into buf: inout [UInt8]) { + switch value { + + + case .comfortable: + writeInt(&buf, Int32(1)) + + + case .compact: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeUserSettingsDensity_lift(_ buf: RustBuffer) throws -> UserSettingsDensity { + return try FfiConverterTypeUserSettingsDensity.lift(buf) +} + +public func FfiConverterTypeUserSettingsDensity_lower(_ value: UserSettingsDensity) -> RustBuffer { + return FfiConverterTypeUserSettingsDensity.lower(value) +} + + +extension UserSettingsDensity: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserSettingsEarlyAccess { + + case regular + case beta +} + +public struct FfiConverterTypeUserSettingsEarlyAccess: FfiConverterRustBuffer { + typealias SwiftType = UserSettingsEarlyAccess + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserSettingsEarlyAccess { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .regular + + case 2: return .beta + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserSettingsEarlyAccess, into buf: inout [UInt8]) { + switch value { + + + case .regular: + writeInt(&buf, Int32(1)) + + + case .beta: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeUserSettingsEarlyAccess_lift(_ buf: RustBuffer) throws -> UserSettingsEarlyAccess { + return try FfiConverterTypeUserSettingsEarlyAccess.lift(buf) +} + +public func FfiConverterTypeUserSettingsEarlyAccess_lower(_ value: UserSettingsEarlyAccess) -> RustBuffer { + return FfiConverterTypeUserSettingsEarlyAccess.lower(value) +} + + +extension UserSettingsEarlyAccess: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserSettingsTimeFormat { + + case `default` + case h24 + case h12 +} + +public struct FfiConverterTypeUserSettingsTimeFormat: FfiConverterRustBuffer { + typealias SwiftType = UserSettingsTimeFormat + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserSettingsTimeFormat { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .`default` + + case 2: return .h24 + + case 3: return .h12 + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserSettingsTimeFormat, into buf: inout [UInt8]) { + switch value { + + + case .`default`: + writeInt(&buf, Int32(1)) + + + case .h24: + writeInt(&buf, Int32(2)) + + + case .h12: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeUserSettingsTimeFormat_lift(_ buf: RustBuffer) throws -> UserSettingsTimeFormat { + return try FfiConverterTypeUserSettingsTimeFormat.lift(buf) +} + +public func FfiConverterTypeUserSettingsTimeFormat_lower(_ value: UserSettingsTimeFormat) -> RustBuffer { + return FfiConverterTypeUserSettingsTimeFormat.lower(value) +} + + +extension UserSettingsTimeFormat: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserSettingsWeekStart { + + case `default` + case monday + case saturday + case sunday +} + +public struct FfiConverterTypeUserSettingsWeekStart: FfiConverterRustBuffer { + typealias SwiftType = UserSettingsWeekStart + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserSettingsWeekStart { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .`default` + + case 2: return .monday + + case 3: return .saturday + + case 4: return .sunday + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserSettingsWeekStart, into buf: inout [UInt8]) { + switch value { + + + case .`default`: + writeInt(&buf, Int32(1)) + + + case .monday: + writeInt(&buf, Int32(2)) + + + case .saturday: + writeInt(&buf, Int32(3)) + + + case .sunday: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeUserSettingsWeekStart_lift(_ buf: RustBuffer) throws -> UserSettingsWeekStart { + return try FfiConverterTypeUserSettingsWeekStart.lift(buf) +} + +public func FfiConverterTypeUserSettingsWeekStart_lower(_ value: UserSettingsWeekStart) -> RustBuffer { + return FfiConverterTypeUserSettingsWeekStart.lower(value) +} + + +extension UserSettingsWeekStart: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum UserType { + + case proton + case managed + case external +} + +public struct FfiConverterTypeUserType: FfiConverterRustBuffer { + typealias SwiftType = UserType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .proton + + case 2: return .managed + + case 3: return .external + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: UserType, into buf: inout [UInt8]) { + switch value { + + + case .proton: + writeInt(&buf, Int32(1)) + + + case .managed: + writeInt(&buf, Int32(2)) + + + case .external: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeUserType_lift(_ buf: RustBuffer) throws -> UserType { + return try FfiConverterTypeUserType.lift(buf) +} + +public func FfiConverterTypeUserType_lower(_ value: UserType) -> RustBuffer { + return FfiConverterTypeUserType.lower(value) +} + + +extension UserType: Equatable, Hashable {} + + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias Uid = String +public struct FfiConverterTypeUid: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Uid { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: Uid, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> Uid { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: Uid) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeUid_lift(_ value: RustBuffer) throws -> Uid { + return try FfiConverterTypeUid.lift(value) +} + +public func FfiConverterTypeUid_lower(_ value: Uid) -> RustBuffer { + return FfiConverterTypeUid.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias UserId = String +public struct FfiConverterTypeUserId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UserId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: UserId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> UserId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: UserId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeUserId_lift(_ value: RustBuffer) throws -> UserId { + return try FfiConverterTypeUserId.lift(value) +} + +public func FfiConverterTypeUserId_lower(_ value: UserId) -> RustBuffer { + return FfiConverterTypeUserId.lower(value) +} + + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_api_core_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_mail.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_mail.swift new file mode 100644 index 0000000000..0437173ad3 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_api_mail.swift @@ -0,0 +1,2945 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_api_mail_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_api_mail_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { + typealias FfiType = UInt32 + typealias SwiftType = UInt32 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { + typealias FfiType = UInt64 + typealias SwiftType = UInt64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterBool : FfiConverter { + typealias FfiType = Int8 + typealias SwiftType = Bool + + public static func lift(_ value: Int8) throws -> Bool { + return value != 0 + } + + public static func lower(_ value: Bool) -> Int8 { + return value ? 1 : 0 + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Bool, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + +public struct AttachmentMetadata { + public var id: AttachmentId + public var size: UInt64 + public var name: String + public var mimeType: String + public var disposition: Disposition + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: AttachmentId, + size: UInt64, + name: String, + mimeType: String, + disposition: Disposition) { + self.id = id + self.size = size + self.name = name + self.mimeType = mimeType + self.disposition = disposition + } +} + + +extension AttachmentMetadata: Equatable, Hashable { + public static func ==(lhs: AttachmentMetadata, rhs: AttachmentMetadata) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.size != rhs.size { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.mimeType != rhs.mimeType { + return false + } + if lhs.disposition != rhs.disposition { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(size) + hasher.combine(name) + hasher.combine(mimeType) + hasher.combine(disposition) + } +} + + +public struct FfiConverterTypeAttachmentMetadata: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AttachmentMetadata { + return + try AttachmentMetadata( + id: FfiConverterTypeAttachmentId.read(from: &buf), + size: FfiConverterUInt64.read(from: &buf), + name: FfiConverterString.read(from: &buf), + mimeType: FfiConverterString.read(from: &buf), + disposition: FfiConverterTypeDisposition.read(from: &buf) + ) + } + + public static func write(_ value: AttachmentMetadata, into buf: inout [UInt8]) { + FfiConverterTypeAttachmentId.write(value.id, into: &buf) + FfiConverterUInt64.write(value.size, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterString.write(value.mimeType, into: &buf) + FfiConverterTypeDisposition.write(value.disposition, into: &buf) + } +} + + +public func FfiConverterTypeAttachmentMetadata_lift(_ buf: RustBuffer) throws -> AttachmentMetadata { + return try FfiConverterTypeAttachmentMetadata.lift(buf) +} + +public func FfiConverterTypeAttachmentMetadata_lower(_ value: AttachmentMetadata) -> RustBuffer { + return FfiConverterTypeAttachmentMetadata.lower(value) +} + + +public struct Label { + public var id: LabelId + public var parentId: LabelId? + public var name: String + public var path: String? + public var color: String + public var labelType: LabelType + public var notify: ProtonBoolean + public var display: ProtonBoolean + public var sticky: ProtonBoolean + public var expanded: ProtonBoolean + public var order: UInt32 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: LabelId, + parentId: LabelId?, + name: String, + path: String?, + color: String, + labelType: LabelType, + notify: ProtonBoolean, + display: ProtonBoolean, + sticky: ProtonBoolean, + expanded: ProtonBoolean, + order: UInt32) { + self.id = id + self.parentId = parentId + self.name = name + self.path = path + self.color = color + self.labelType = labelType + self.notify = notify + self.display = display + self.sticky = sticky + self.expanded = expanded + self.order = order + } +} + + +extension Label: Equatable, Hashable { + public static func ==(lhs: Label, rhs: Label) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.parentId != rhs.parentId { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.path != rhs.path { + return false + } + if lhs.color != rhs.color { + return false + } + if lhs.labelType != rhs.labelType { + return false + } + if lhs.notify != rhs.notify { + return false + } + if lhs.display != rhs.display { + return false + } + if lhs.sticky != rhs.sticky { + return false + } + if lhs.expanded != rhs.expanded { + return false + } + if lhs.order != rhs.order { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(parentId) + hasher.combine(name) + hasher.combine(path) + hasher.combine(color) + hasher.combine(labelType) + hasher.combine(notify) + hasher.combine(display) + hasher.combine(sticky) + hasher.combine(expanded) + hasher.combine(order) + } +} + + +public struct FfiConverterTypeLabel: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Label { + return + try Label( + id: FfiConverterTypeLabelId.read(from: &buf), + parentId: FfiConverterOptionTypeLabelId.read(from: &buf), + name: FfiConverterString.read(from: &buf), + path: FfiConverterOptionString.read(from: &buf), + color: FfiConverterString.read(from: &buf), + labelType: FfiConverterTypeLabelType.read(from: &buf), + notify: FfiConverterTypeProtonBoolean.read(from: &buf), + display: FfiConverterTypeProtonBoolean.read(from: &buf), + sticky: FfiConverterTypeProtonBoolean.read(from: &buf), + expanded: FfiConverterTypeProtonBoolean.read(from: &buf), + order: FfiConverterUInt32.read(from: &buf) + ) + } + + public static func write(_ value: Label, into buf: inout [UInt8]) { + FfiConverterTypeLabelId.write(value.id, into: &buf) + FfiConverterOptionTypeLabelId.write(value.parentId, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.path, into: &buf) + FfiConverterString.write(value.color, into: &buf) + FfiConverterTypeLabelType.write(value.labelType, into: &buf) + FfiConverterTypeProtonBoolean.write(value.notify, into: &buf) + FfiConverterTypeProtonBoolean.write(value.display, into: &buf) + FfiConverterTypeProtonBoolean.write(value.sticky, into: &buf) + FfiConverterTypeProtonBoolean.write(value.expanded, into: &buf) + FfiConverterUInt32.write(value.order, into: &buf) + } +} + + +public func FfiConverterTypeLabel_lift(_ buf: RustBuffer) throws -> Label { + return try FfiConverterTypeLabel.lift(buf) +} + +public func FfiConverterTypeLabel_lower(_ value: Label) -> RustBuffer { + return FfiConverterTypeLabel.lower(value) +} + + +public struct MailSettings { + public var displayName: String + public var signature: String + public var theme: String + public var autoSaveContacts: ProtonBoolean + public var composerMode: MailSettingsComposerMode + public var messageButtons: MailSettingsMessageButtons + public var showImages: MailSettingsShowImages + public var showMoved: MailSettingsShowMoved + public var autoDeleteSpamAndTrashDays: UInt32? + public var almostAllMail: MailSettingsAlmostAllMail + public var nextMessageOnMove: MailSettingsNextMessageOnMove? + public var viewMode: MailSettingsViewMode + public var viewLayout: MailSettingsViewLayout + public var swipeLeft: MailSettingsSwipeAction + public var swipeRight: MailSettingsSwipeAction + public var shortcuts: ProtonBoolean + public var pmSignature: MailSettingsPmSignature + public var pmSignatureReferralLink: ProtonBoolean + public var imageProxy: UInt32 + public var numMessagePerPage: UInt32 + public var draftMimeType: String + public var receiveMimeType: String + public var showMimeType: String + public var enableFolderColor: ProtonBoolean + public var inheritParentFolderColor: ProtonBoolean + public var submissionAccess: ProtonBoolean + public var rightToLeft: MailSettingsComposerDirection + public var attachPublicKey: ProtonBoolean + public var sign: ProtonBoolean + public var pgpScheme: MailSettingsPgpScheme + public var promptPin: ProtonBoolean + public var stickyLabels: ProtonBoolean + public var confirmLink: ProtonBoolean + public var delaySendSeconds: UInt32 + public var fontFace: String? + public var spamAction: MailSettingsSpamAction? + public var blockSenderConfirmation: ProtonBoolean? + public var mobileSettings: MailSettingsMobileSettings? + public var hideRemoteImages: ProtonBoolean + public var hideSenderImages: ProtonBoolean + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + displayName: String, + signature: String, + theme: String, + autoSaveContacts: ProtonBoolean, + composerMode: MailSettingsComposerMode, + messageButtons: MailSettingsMessageButtons, + showImages: MailSettingsShowImages, + showMoved: MailSettingsShowMoved, + autoDeleteSpamAndTrashDays: UInt32?, + almostAllMail: MailSettingsAlmostAllMail, + nextMessageOnMove: MailSettingsNextMessageOnMove?, + viewMode: MailSettingsViewMode, + viewLayout: MailSettingsViewLayout, + swipeLeft: MailSettingsSwipeAction, + swipeRight: MailSettingsSwipeAction, + shortcuts: ProtonBoolean, + pmSignature: MailSettingsPmSignature, + pmSignatureReferralLink: ProtonBoolean, + imageProxy: UInt32, + numMessagePerPage: UInt32, + draftMimeType: String, + receiveMimeType: String, + showMimeType: String, + enableFolderColor: ProtonBoolean, + inheritParentFolderColor: ProtonBoolean, + submissionAccess: ProtonBoolean, + rightToLeft: MailSettingsComposerDirection, + attachPublicKey: ProtonBoolean, + sign: ProtonBoolean, + pgpScheme: MailSettingsPgpScheme, + promptPin: ProtonBoolean, + stickyLabels: ProtonBoolean, + confirmLink: ProtonBoolean, + delaySendSeconds: UInt32, + fontFace: String?, + spamAction: MailSettingsSpamAction?, + blockSenderConfirmation: ProtonBoolean?, + mobileSettings: MailSettingsMobileSettings?, + hideRemoteImages: ProtonBoolean, + hideSenderImages: ProtonBoolean) { + self.displayName = displayName + self.signature = signature + self.theme = theme + self.autoSaveContacts = autoSaveContacts + self.composerMode = composerMode + self.messageButtons = messageButtons + self.showImages = showImages + self.showMoved = showMoved + self.autoDeleteSpamAndTrashDays = autoDeleteSpamAndTrashDays + self.almostAllMail = almostAllMail + self.nextMessageOnMove = nextMessageOnMove + self.viewMode = viewMode + self.viewLayout = viewLayout + self.swipeLeft = swipeLeft + self.swipeRight = swipeRight + self.shortcuts = shortcuts + self.pmSignature = pmSignature + self.pmSignatureReferralLink = pmSignatureReferralLink + self.imageProxy = imageProxy + self.numMessagePerPage = numMessagePerPage + self.draftMimeType = draftMimeType + self.receiveMimeType = receiveMimeType + self.showMimeType = showMimeType + self.enableFolderColor = enableFolderColor + self.inheritParentFolderColor = inheritParentFolderColor + self.submissionAccess = submissionAccess + self.rightToLeft = rightToLeft + self.attachPublicKey = attachPublicKey + self.sign = sign + self.pgpScheme = pgpScheme + self.promptPin = promptPin + self.stickyLabels = stickyLabels + self.confirmLink = confirmLink + self.delaySendSeconds = delaySendSeconds + self.fontFace = fontFace + self.spamAction = spamAction + self.blockSenderConfirmation = blockSenderConfirmation + self.mobileSettings = mobileSettings + self.hideRemoteImages = hideRemoteImages + self.hideSenderImages = hideSenderImages + } +} + + +extension MailSettings: Equatable, Hashable { + public static func ==(lhs: MailSettings, rhs: MailSettings) -> Bool { + if lhs.displayName != rhs.displayName { + return false + } + if lhs.signature != rhs.signature { + return false + } + if lhs.theme != rhs.theme { + return false + } + if lhs.autoSaveContacts != rhs.autoSaveContacts { + return false + } + if lhs.composerMode != rhs.composerMode { + return false + } + if lhs.messageButtons != rhs.messageButtons { + return false + } + if lhs.showImages != rhs.showImages { + return false + } + if lhs.showMoved != rhs.showMoved { + return false + } + if lhs.autoDeleteSpamAndTrashDays != rhs.autoDeleteSpamAndTrashDays { + return false + } + if lhs.almostAllMail != rhs.almostAllMail { + return false + } + if lhs.nextMessageOnMove != rhs.nextMessageOnMove { + return false + } + if lhs.viewMode != rhs.viewMode { + return false + } + if lhs.viewLayout != rhs.viewLayout { + return false + } + if lhs.swipeLeft != rhs.swipeLeft { + return false + } + if lhs.swipeRight != rhs.swipeRight { + return false + } + if lhs.shortcuts != rhs.shortcuts { + return false + } + if lhs.pmSignature != rhs.pmSignature { + return false + } + if lhs.pmSignatureReferralLink != rhs.pmSignatureReferralLink { + return false + } + if lhs.imageProxy != rhs.imageProxy { + return false + } + if lhs.numMessagePerPage != rhs.numMessagePerPage { + return false + } + if lhs.draftMimeType != rhs.draftMimeType { + return false + } + if lhs.receiveMimeType != rhs.receiveMimeType { + return false + } + if lhs.showMimeType != rhs.showMimeType { + return false + } + if lhs.enableFolderColor != rhs.enableFolderColor { + return false + } + if lhs.inheritParentFolderColor != rhs.inheritParentFolderColor { + return false + } + if lhs.submissionAccess != rhs.submissionAccess { + return false + } + if lhs.rightToLeft != rhs.rightToLeft { + return false + } + if lhs.attachPublicKey != rhs.attachPublicKey { + return false + } + if lhs.sign != rhs.sign { + return false + } + if lhs.pgpScheme != rhs.pgpScheme { + return false + } + if lhs.promptPin != rhs.promptPin { + return false + } + if lhs.stickyLabels != rhs.stickyLabels { + return false + } + if lhs.confirmLink != rhs.confirmLink { + return false + } + if lhs.delaySendSeconds != rhs.delaySendSeconds { + return false + } + if lhs.fontFace != rhs.fontFace { + return false + } + if lhs.spamAction != rhs.spamAction { + return false + } + if lhs.blockSenderConfirmation != rhs.blockSenderConfirmation { + return false + } + if lhs.mobileSettings != rhs.mobileSettings { + return false + } + if lhs.hideRemoteImages != rhs.hideRemoteImages { + return false + } + if lhs.hideSenderImages != rhs.hideSenderImages { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(displayName) + hasher.combine(signature) + hasher.combine(theme) + hasher.combine(autoSaveContacts) + hasher.combine(composerMode) + hasher.combine(messageButtons) + hasher.combine(showImages) + hasher.combine(showMoved) + hasher.combine(autoDeleteSpamAndTrashDays) + hasher.combine(almostAllMail) + hasher.combine(nextMessageOnMove) + hasher.combine(viewMode) + hasher.combine(viewLayout) + hasher.combine(swipeLeft) + hasher.combine(swipeRight) + hasher.combine(shortcuts) + hasher.combine(pmSignature) + hasher.combine(pmSignatureReferralLink) + hasher.combine(imageProxy) + hasher.combine(numMessagePerPage) + hasher.combine(draftMimeType) + hasher.combine(receiveMimeType) + hasher.combine(showMimeType) + hasher.combine(enableFolderColor) + hasher.combine(inheritParentFolderColor) + hasher.combine(submissionAccess) + hasher.combine(rightToLeft) + hasher.combine(attachPublicKey) + hasher.combine(sign) + hasher.combine(pgpScheme) + hasher.combine(promptPin) + hasher.combine(stickyLabels) + hasher.combine(confirmLink) + hasher.combine(delaySendSeconds) + hasher.combine(fontFace) + hasher.combine(spamAction) + hasher.combine(blockSenderConfirmation) + hasher.combine(mobileSettings) + hasher.combine(hideRemoteImages) + hasher.combine(hideSenderImages) + } +} + + +public struct FfiConverterTypeMailSettings: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettings { + return + try MailSettings( + displayName: FfiConverterString.read(from: &buf), + signature: FfiConverterString.read(from: &buf), + theme: FfiConverterString.read(from: &buf), + autoSaveContacts: FfiConverterTypeProtonBoolean.read(from: &buf), + composerMode: FfiConverterTypeMailSettingsComposerMode.read(from: &buf), + messageButtons: FfiConverterTypeMailSettingsMessageButtons.read(from: &buf), + showImages: FfiConverterTypeMailSettingsShowImages.read(from: &buf), + showMoved: FfiConverterTypeMailSettingsShowMoved.read(from: &buf), + autoDeleteSpamAndTrashDays: FfiConverterOptionUInt32.read(from: &buf), + almostAllMail: FfiConverterTypeMailSettingsAlmostAllMail.read(from: &buf), + nextMessageOnMove: FfiConverterOptionTypeMailSettingsNextMessageOnMove.read(from: &buf), + viewMode: FfiConverterTypeMailSettingsViewMode.read(from: &buf), + viewLayout: FfiConverterTypeMailSettingsViewLayout.read(from: &buf), + swipeLeft: FfiConverterTypeMailSettingsSwipeAction.read(from: &buf), + swipeRight: FfiConverterTypeMailSettingsSwipeAction.read(from: &buf), + shortcuts: FfiConverterTypeProtonBoolean.read(from: &buf), + pmSignature: FfiConverterTypeMailSettingsPMSignature.read(from: &buf), + pmSignatureReferralLink: FfiConverterTypeProtonBoolean.read(from: &buf), + imageProxy: FfiConverterUInt32.read(from: &buf), + numMessagePerPage: FfiConverterUInt32.read(from: &buf), + draftMimeType: FfiConverterString.read(from: &buf), + receiveMimeType: FfiConverterString.read(from: &buf), + showMimeType: FfiConverterString.read(from: &buf), + enableFolderColor: FfiConverterTypeProtonBoolean.read(from: &buf), + inheritParentFolderColor: FfiConverterTypeProtonBoolean.read(from: &buf), + submissionAccess: FfiConverterTypeProtonBoolean.read(from: &buf), + rightToLeft: FfiConverterTypeMailSettingsComposerDirection.read(from: &buf), + attachPublicKey: FfiConverterTypeProtonBoolean.read(from: &buf), + sign: FfiConverterTypeProtonBoolean.read(from: &buf), + pgpScheme: FfiConverterTypeMailSettingsPGPScheme.read(from: &buf), + promptPin: FfiConverterTypeProtonBoolean.read(from: &buf), + stickyLabels: FfiConverterTypeProtonBoolean.read(from: &buf), + confirmLink: FfiConverterTypeProtonBoolean.read(from: &buf), + delaySendSeconds: FfiConverterUInt32.read(from: &buf), + fontFace: FfiConverterOptionString.read(from: &buf), + spamAction: FfiConverterOptionTypeMailSettingsSpamAction.read(from: &buf), + blockSenderConfirmation: FfiConverterOptionTypeProtonBoolean.read(from: &buf), + mobileSettings: FfiConverterOptionTypeMailSettingsMobileSettings.read(from: &buf), + hideRemoteImages: FfiConverterTypeProtonBoolean.read(from: &buf), + hideSenderImages: FfiConverterTypeProtonBoolean.read(from: &buf) + ) + } + + public static func write(_ value: MailSettings, into buf: inout [UInt8]) { + FfiConverterString.write(value.displayName, into: &buf) + FfiConverterString.write(value.signature, into: &buf) + FfiConverterString.write(value.theme, into: &buf) + FfiConverterTypeProtonBoolean.write(value.autoSaveContacts, into: &buf) + FfiConverterTypeMailSettingsComposerMode.write(value.composerMode, into: &buf) + FfiConverterTypeMailSettingsMessageButtons.write(value.messageButtons, into: &buf) + FfiConverterTypeMailSettingsShowImages.write(value.showImages, into: &buf) + FfiConverterTypeMailSettingsShowMoved.write(value.showMoved, into: &buf) + FfiConverterOptionUInt32.write(value.autoDeleteSpamAndTrashDays, into: &buf) + FfiConverterTypeMailSettingsAlmostAllMail.write(value.almostAllMail, into: &buf) + FfiConverterOptionTypeMailSettingsNextMessageOnMove.write(value.nextMessageOnMove, into: &buf) + FfiConverterTypeMailSettingsViewMode.write(value.viewMode, into: &buf) + FfiConverterTypeMailSettingsViewLayout.write(value.viewLayout, into: &buf) + FfiConverterTypeMailSettingsSwipeAction.write(value.swipeLeft, into: &buf) + FfiConverterTypeMailSettingsSwipeAction.write(value.swipeRight, into: &buf) + FfiConverterTypeProtonBoolean.write(value.shortcuts, into: &buf) + FfiConverterTypeMailSettingsPMSignature.write(value.pmSignature, into: &buf) + FfiConverterTypeProtonBoolean.write(value.pmSignatureReferralLink, into: &buf) + FfiConverterUInt32.write(value.imageProxy, into: &buf) + FfiConverterUInt32.write(value.numMessagePerPage, into: &buf) + FfiConverterString.write(value.draftMimeType, into: &buf) + FfiConverterString.write(value.receiveMimeType, into: &buf) + FfiConverterString.write(value.showMimeType, into: &buf) + FfiConverterTypeProtonBoolean.write(value.enableFolderColor, into: &buf) + FfiConverterTypeProtonBoolean.write(value.inheritParentFolderColor, into: &buf) + FfiConverterTypeProtonBoolean.write(value.submissionAccess, into: &buf) + FfiConverterTypeMailSettingsComposerDirection.write(value.rightToLeft, into: &buf) + FfiConverterTypeProtonBoolean.write(value.attachPublicKey, into: &buf) + FfiConverterTypeProtonBoolean.write(value.sign, into: &buf) + FfiConverterTypeMailSettingsPGPScheme.write(value.pgpScheme, into: &buf) + FfiConverterTypeProtonBoolean.write(value.promptPin, into: &buf) + FfiConverterTypeProtonBoolean.write(value.stickyLabels, into: &buf) + FfiConverterTypeProtonBoolean.write(value.confirmLink, into: &buf) + FfiConverterUInt32.write(value.delaySendSeconds, into: &buf) + FfiConverterOptionString.write(value.fontFace, into: &buf) + FfiConverterOptionTypeMailSettingsSpamAction.write(value.spamAction, into: &buf) + FfiConverterOptionTypeProtonBoolean.write(value.blockSenderConfirmation, into: &buf) + FfiConverterOptionTypeMailSettingsMobileSettings.write(value.mobileSettings, into: &buf) + FfiConverterTypeProtonBoolean.write(value.hideRemoteImages, into: &buf) + FfiConverterTypeProtonBoolean.write(value.hideSenderImages, into: &buf) + } +} + + +public func FfiConverterTypeMailSettings_lift(_ buf: RustBuffer) throws -> MailSettings { + return try FfiConverterTypeMailSettings.lift(buf) +} + +public func FfiConverterTypeMailSettings_lower(_ value: MailSettings) -> RustBuffer { + return FfiConverterTypeMailSettings.lower(value) +} + + +public struct MailSettingsMobileSetting { + public var isCustom: Bool + public var actions: [String] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + isCustom: Bool, + actions: [String]) { + self.isCustom = isCustom + self.actions = actions + } +} + + +extension MailSettingsMobileSetting: Equatable, Hashable { + public static func ==(lhs: MailSettingsMobileSetting, rhs: MailSettingsMobileSetting) -> Bool { + if lhs.isCustom != rhs.isCustom { + return false + } + if lhs.actions != rhs.actions { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(isCustom) + hasher.combine(actions) + } +} + + +public struct FfiConverterTypeMailSettingsMobileSetting: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsMobileSetting { + return + try MailSettingsMobileSetting( + isCustom: FfiConverterBool.read(from: &buf), + actions: FfiConverterSequenceString.read(from: &buf) + ) + } + + public static func write(_ value: MailSettingsMobileSetting, into buf: inout [UInt8]) { + FfiConverterBool.write(value.isCustom, into: &buf) + FfiConverterSequenceString.write(value.actions, into: &buf) + } +} + + +public func FfiConverterTypeMailSettingsMobileSetting_lift(_ buf: RustBuffer) throws -> MailSettingsMobileSetting { + return try FfiConverterTypeMailSettingsMobileSetting.lift(buf) +} + +public func FfiConverterTypeMailSettingsMobileSetting_lower(_ value: MailSettingsMobileSetting) -> RustBuffer { + return FfiConverterTypeMailSettingsMobileSetting.lower(value) +} + + +public struct MailSettingsMobileSettings { + public var messageToolbar: MailSettingsMobileSetting + public var conversationToolbar: MailSettingsMobileSetting + public var listToolbar: MailSettingsMobileSetting + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + messageToolbar: MailSettingsMobileSetting, + conversationToolbar: MailSettingsMobileSetting, + listToolbar: MailSettingsMobileSetting) { + self.messageToolbar = messageToolbar + self.conversationToolbar = conversationToolbar + self.listToolbar = listToolbar + } +} + + +extension MailSettingsMobileSettings: Equatable, Hashable { + public static func ==(lhs: MailSettingsMobileSettings, rhs: MailSettingsMobileSettings) -> Bool { + if lhs.messageToolbar != rhs.messageToolbar { + return false + } + if lhs.conversationToolbar != rhs.conversationToolbar { + return false + } + if lhs.listToolbar != rhs.listToolbar { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(messageToolbar) + hasher.combine(conversationToolbar) + hasher.combine(listToolbar) + } +} + + +public struct FfiConverterTypeMailSettingsMobileSettings: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsMobileSettings { + return + try MailSettingsMobileSettings( + messageToolbar: FfiConverterTypeMailSettingsMobileSetting.read(from: &buf), + conversationToolbar: FfiConverterTypeMailSettingsMobileSetting.read(from: &buf), + listToolbar: FfiConverterTypeMailSettingsMobileSetting.read(from: &buf) + ) + } + + public static func write(_ value: MailSettingsMobileSettings, into buf: inout [UInt8]) { + FfiConverterTypeMailSettingsMobileSetting.write(value.messageToolbar, into: &buf) + FfiConverterTypeMailSettingsMobileSetting.write(value.conversationToolbar, into: &buf) + FfiConverterTypeMailSettingsMobileSetting.write(value.listToolbar, into: &buf) + } +} + + +public func FfiConverterTypeMailSettingsMobileSettings_lift(_ buf: RustBuffer) throws -> MailSettingsMobileSettings { + return try FfiConverterTypeMailSettingsMobileSettings.lift(buf) +} + +public func FfiConverterTypeMailSettingsMobileSettings_lower(_ value: MailSettingsMobileSettings) -> RustBuffer { + return FfiConverterTypeMailSettingsMobileSettings.lower(value) +} + + +public struct MessageAddress { + public var address: String + public var name: String + public var isProton: ProtonBoolean + public var displaySenderImage: ProtonBoolean + public var isSimpleLogin: ProtonBoolean + public var bimiSelector: String? + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + address: String, + name: String, + isProton: ProtonBoolean, + displaySenderImage: ProtonBoolean, + isSimpleLogin: ProtonBoolean, + bimiSelector: String?) { + self.address = address + self.name = name + self.isProton = isProton + self.displaySenderImage = displaySenderImage + self.isSimpleLogin = isSimpleLogin + self.bimiSelector = bimiSelector + } +} + + +extension MessageAddress: Equatable, Hashable { + public static func ==(lhs: MessageAddress, rhs: MessageAddress) -> Bool { + if lhs.address != rhs.address { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.isProton != rhs.isProton { + return false + } + if lhs.displaySenderImage != rhs.displaySenderImage { + return false + } + if lhs.isSimpleLogin != rhs.isSimpleLogin { + return false + } + if lhs.bimiSelector != rhs.bimiSelector { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(address) + hasher.combine(name) + hasher.combine(isProton) + hasher.combine(displaySenderImage) + hasher.combine(isSimpleLogin) + hasher.combine(bimiSelector) + } +} + + +public struct FfiConverterTypeMessageAddress: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MessageAddress { + return + try MessageAddress( + address: FfiConverterString.read(from: &buf), + name: FfiConverterString.read(from: &buf), + isProton: FfiConverterTypeProtonBoolean.read(from: &buf), + displaySenderImage: FfiConverterTypeProtonBoolean.read(from: &buf), + isSimpleLogin: FfiConverterTypeProtonBoolean.read(from: &buf), + bimiSelector: FfiConverterOptionString.read(from: &buf) + ) + } + + public static func write(_ value: MessageAddress, into buf: inout [UInt8]) { + FfiConverterString.write(value.address, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeProtonBoolean.write(value.isProton, into: &buf) + FfiConverterTypeProtonBoolean.write(value.displaySenderImage, into: &buf) + FfiConverterTypeProtonBoolean.write(value.isSimpleLogin, into: &buf) + FfiConverterOptionString.write(value.bimiSelector, into: &buf) + } +} + + +public func FfiConverterTypeMessageAddress_lift(_ buf: RustBuffer) throws -> MessageAddress { + return try FfiConverterTypeMessageAddress.lift(buf) +} + +public func FfiConverterTypeMessageAddress_lower(_ value: MessageAddress) -> RustBuffer { + return FfiConverterTypeMessageAddress.lower(value) +} + + +public struct MessageMetadata { + public var id: MessageId + public var conversationId: ConversationId + public var order: UInt64 + public var addressId: AddressId + public var labelIds: [LabelId] + public var externalId: ExternalId? + public var subject: String + public var sender: MessageAddress + public var toList: [MessageAddress] + public var ccList: [MessageAddress] + public var bccList: [MessageAddress] + public var replyTos: [MessageAddress] + public var flags: UInt64 + public var time: UInt64 + public var size: UInt64 + public var unread: ProtonBoolean + public var isReplied: ProtonBoolean + public var isRepliedAll: ProtonBoolean + public var isForwarded: ProtonBoolean + public var expirationTime: UInt64 + public var numAttachments: UInt32 + public var attachmentsMetadata: [AttachmentMetadata] + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: MessageId, + conversationId: ConversationId, + order: UInt64, + addressId: AddressId, + labelIds: [LabelId], + externalId: ExternalId?, + subject: String, + sender: MessageAddress, + toList: [MessageAddress], + ccList: [MessageAddress], + bccList: [MessageAddress], + replyTos: [MessageAddress], + flags: UInt64, + time: UInt64, + size: UInt64, + unread: ProtonBoolean, + isReplied: ProtonBoolean, + isRepliedAll: ProtonBoolean, + isForwarded: ProtonBoolean, + expirationTime: UInt64, + numAttachments: UInt32, + attachmentsMetadata: [AttachmentMetadata]) { + self.id = id + self.conversationId = conversationId + self.order = order + self.addressId = addressId + self.labelIds = labelIds + self.externalId = externalId + self.subject = subject + self.sender = sender + self.toList = toList + self.ccList = ccList + self.bccList = bccList + self.replyTos = replyTos + self.flags = flags + self.time = time + self.size = size + self.unread = unread + self.isReplied = isReplied + self.isRepliedAll = isRepliedAll + self.isForwarded = isForwarded + self.expirationTime = expirationTime + self.numAttachments = numAttachments + self.attachmentsMetadata = attachmentsMetadata + } +} + + +extension MessageMetadata: Equatable, Hashable { + public static func ==(lhs: MessageMetadata, rhs: MessageMetadata) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.conversationId != rhs.conversationId { + return false + } + if lhs.order != rhs.order { + return false + } + if lhs.addressId != rhs.addressId { + return false + } + if lhs.labelIds != rhs.labelIds { + return false + } + if lhs.externalId != rhs.externalId { + return false + } + if lhs.subject != rhs.subject { + return false + } + if lhs.sender != rhs.sender { + return false + } + if lhs.toList != rhs.toList { + return false + } + if lhs.ccList != rhs.ccList { + return false + } + if lhs.bccList != rhs.bccList { + return false + } + if lhs.replyTos != rhs.replyTos { + return false + } + if lhs.flags != rhs.flags { + return false + } + if lhs.time != rhs.time { + return false + } + if lhs.size != rhs.size { + return false + } + if lhs.unread != rhs.unread { + return false + } + if lhs.isReplied != rhs.isReplied { + return false + } + if lhs.isRepliedAll != rhs.isRepliedAll { + return false + } + if lhs.isForwarded != rhs.isForwarded { + return false + } + if lhs.expirationTime != rhs.expirationTime { + return false + } + if lhs.numAttachments != rhs.numAttachments { + return false + } + if lhs.attachmentsMetadata != rhs.attachmentsMetadata { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(conversationId) + hasher.combine(order) + hasher.combine(addressId) + hasher.combine(labelIds) + hasher.combine(externalId) + hasher.combine(subject) + hasher.combine(sender) + hasher.combine(toList) + hasher.combine(ccList) + hasher.combine(bccList) + hasher.combine(replyTos) + hasher.combine(flags) + hasher.combine(time) + hasher.combine(size) + hasher.combine(unread) + hasher.combine(isReplied) + hasher.combine(isRepliedAll) + hasher.combine(isForwarded) + hasher.combine(expirationTime) + hasher.combine(numAttachments) + hasher.combine(attachmentsMetadata) + } +} + + +public struct FfiConverterTypeMessageMetadata: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MessageMetadata { + return + try MessageMetadata( + id: FfiConverterTypeMessageId.read(from: &buf), + conversationId: FfiConverterTypeConversationId.read(from: &buf), + order: FfiConverterUInt64.read(from: &buf), + addressId: FfiConverterTypeAddressId.read(from: &buf), + labelIds: FfiConverterSequenceTypeLabelId.read(from: &buf), + externalId: FfiConverterOptionTypeExternalId.read(from: &buf), + subject: FfiConverterString.read(from: &buf), + sender: FfiConverterTypeMessageAddress.read(from: &buf), + toList: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + ccList: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + bccList: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + replyTos: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + flags: FfiConverterUInt64.read(from: &buf), + time: FfiConverterUInt64.read(from: &buf), + size: FfiConverterUInt64.read(from: &buf), + unread: FfiConverterTypeProtonBoolean.read(from: &buf), + isReplied: FfiConverterTypeProtonBoolean.read(from: &buf), + isRepliedAll: FfiConverterTypeProtonBoolean.read(from: &buf), + isForwarded: FfiConverterTypeProtonBoolean.read(from: &buf), + expirationTime: FfiConverterUInt64.read(from: &buf), + numAttachments: FfiConverterUInt32.read(from: &buf), + attachmentsMetadata: FfiConverterSequenceTypeAttachmentMetadata.read(from: &buf) + ) + } + + public static func write(_ value: MessageMetadata, into buf: inout [UInt8]) { + FfiConverterTypeMessageId.write(value.id, into: &buf) + FfiConverterTypeConversationId.write(value.conversationId, into: &buf) + FfiConverterUInt64.write(value.order, into: &buf) + FfiConverterTypeAddressId.write(value.addressId, into: &buf) + FfiConverterSequenceTypeLabelId.write(value.labelIds, into: &buf) + FfiConverterOptionTypeExternalId.write(value.externalId, into: &buf) + FfiConverterString.write(value.subject, into: &buf) + FfiConverterTypeMessageAddress.write(value.sender, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.toList, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.ccList, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.bccList, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.replyTos, into: &buf) + FfiConverterUInt64.write(value.flags, into: &buf) + FfiConverterUInt64.write(value.time, into: &buf) + FfiConverterUInt64.write(value.size, into: &buf) + FfiConverterTypeProtonBoolean.write(value.unread, into: &buf) + FfiConverterTypeProtonBoolean.write(value.isReplied, into: &buf) + FfiConverterTypeProtonBoolean.write(value.isRepliedAll, into: &buf) + FfiConverterTypeProtonBoolean.write(value.isForwarded, into: &buf) + FfiConverterUInt64.write(value.expirationTime, into: &buf) + FfiConverterUInt32.write(value.numAttachments, into: &buf) + FfiConverterSequenceTypeAttachmentMetadata.write(value.attachmentsMetadata, into: &buf) + } +} + + +public func FfiConverterTypeMessageMetadata_lift(_ buf: RustBuffer) throws -> MessageMetadata { + return try FfiConverterTypeMessageMetadata.lift(buf) +} + +public func FfiConverterTypeMessageMetadata_lower(_ value: MessageMetadata) -> RustBuffer { + return FfiConverterTypeMessageMetadata.lower(value) +} + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum AddressStatus { + + case disabled + case enabled + case deleting +} + +public struct FfiConverterTypeAddressStatus: FfiConverterRustBuffer { + typealias SwiftType = AddressStatus + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressStatus { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .disabled + + case 2: return .enabled + + case 3: return .deleting + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AddressStatus, into buf: inout [UInt8]) { + switch value { + + + case .disabled: + writeInt(&buf, Int32(1)) + + + case .enabled: + writeInt(&buf, Int32(2)) + + + case .deleting: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeAddressStatus_lift(_ buf: RustBuffer) throws -> AddressStatus { + return try FfiConverterTypeAddressStatus.lift(buf) +} + +public func FfiConverterTypeAddressStatus_lower(_ value: AddressStatus) -> RustBuffer { + return FfiConverterTypeAddressStatus.lower(value) +} + + +extension AddressStatus: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum AddressType { + + case original + case alias + case custom + case premium + case external +} + +public struct FfiConverterTypeAddressType: FfiConverterRustBuffer { + typealias SwiftType = AddressType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .original + + case 2: return .alias + + case 3: return .custom + + case 4: return .premium + + case 5: return .external + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: AddressType, into buf: inout [UInt8]) { + switch value { + + + case .original: + writeInt(&buf, Int32(1)) + + + case .alias: + writeInt(&buf, Int32(2)) + + + case .custom: + writeInt(&buf, Int32(3)) + + + case .premium: + writeInt(&buf, Int32(4)) + + + case .external: + writeInt(&buf, Int32(5)) + + } + } +} + + +public func FfiConverterTypeAddressType_lift(_ buf: RustBuffer) throws -> AddressType { + return try FfiConverterTypeAddressType.lift(buf) +} + +public func FfiConverterTypeAddressType_lower(_ value: AddressType) -> RustBuffer { + return FfiConverterTypeAddressType.lower(value) +} + + +extension AddressType: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum Disposition { + + case inline + case attachment +} + +public struct FfiConverterTypeDisposition: FfiConverterRustBuffer { + typealias SwiftType = Disposition + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Disposition { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .inline + + case 2: return .attachment + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: Disposition, into buf: inout [UInt8]) { + switch value { + + + case .inline: + writeInt(&buf, Int32(1)) + + + case .attachment: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeDisposition_lift(_ buf: RustBuffer) throws -> Disposition { + return try FfiConverterTypeDisposition.lift(buf) +} + +public func FfiConverterTypeDisposition_lower(_ value: Disposition) -> RustBuffer { + return FfiConverterTypeDisposition.lower(value) +} + + +extension Disposition: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum LabelType { + + case label + case contactGroup + case folder + case system +} + +public struct FfiConverterTypeLabelType: FfiConverterRustBuffer { + typealias SwiftType = LabelType + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LabelType { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .label + + case 2: return .contactGroup + + case 3: return .folder + + case 4: return .system + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: LabelType, into buf: inout [UInt8]) { + switch value { + + + case .label: + writeInt(&buf, Int32(1)) + + + case .contactGroup: + writeInt(&buf, Int32(2)) + + + case .folder: + writeInt(&buf, Int32(3)) + + + case .system: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeLabelType_lift(_ buf: RustBuffer) throws -> LabelType { + return try FfiConverterTypeLabelType.lift(buf) +} + +public func FfiConverterTypeLabelType_lower(_ value: LabelType) -> RustBuffer { + return FfiConverterTypeLabelType.lower(value) +} + + +extension LabelType: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsAlmostAllMail { + + case allMail + case almostAllMail +} + +public struct FfiConverterTypeMailSettingsAlmostAllMail: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsAlmostAllMail + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsAlmostAllMail { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .allMail + + case 2: return .almostAllMail + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsAlmostAllMail, into buf: inout [UInt8]) { + switch value { + + + case .allMail: + writeInt(&buf, Int32(1)) + + + case .almostAllMail: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsAlmostAllMail_lift(_ buf: RustBuffer) throws -> MailSettingsAlmostAllMail { + return try FfiConverterTypeMailSettingsAlmostAllMail.lift(buf) +} + +public func FfiConverterTypeMailSettingsAlmostAllMail_lower(_ value: MailSettingsAlmostAllMail) -> RustBuffer { + return FfiConverterTypeMailSettingsAlmostAllMail.lower(value) +} + + +extension MailSettingsAlmostAllMail: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsComposerDirection { + + case leftToRight + case rightToLeft +} + +public struct FfiConverterTypeMailSettingsComposerDirection: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsComposerDirection + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsComposerDirection { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .leftToRight + + case 2: return .rightToLeft + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsComposerDirection, into buf: inout [UInt8]) { + switch value { + + + case .leftToRight: + writeInt(&buf, Int32(1)) + + + case .rightToLeft: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsComposerDirection_lift(_ buf: RustBuffer) throws -> MailSettingsComposerDirection { + return try FfiConverterTypeMailSettingsComposerDirection.lift(buf) +} + +public func FfiConverterTypeMailSettingsComposerDirection_lower(_ value: MailSettingsComposerDirection) -> RustBuffer { + return FfiConverterTypeMailSettingsComposerDirection.lower(value) +} + + +extension MailSettingsComposerDirection: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsComposerMode { + + case normal + case maximized +} + +public struct FfiConverterTypeMailSettingsComposerMode: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsComposerMode + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsComposerMode { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .normal + + case 2: return .maximized + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsComposerMode, into buf: inout [UInt8]) { + switch value { + + + case .normal: + writeInt(&buf, Int32(1)) + + + case .maximized: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsComposerMode_lift(_ buf: RustBuffer) throws -> MailSettingsComposerMode { + return try FfiConverterTypeMailSettingsComposerMode.lift(buf) +} + +public func FfiConverterTypeMailSettingsComposerMode_lower(_ value: MailSettingsComposerMode) -> RustBuffer { + return FfiConverterTypeMailSettingsComposerMode.lower(value) +} + + +extension MailSettingsComposerMode: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsMessageButtons { + + case readFirst + case unreadFirst +} + +public struct FfiConverterTypeMailSettingsMessageButtons: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsMessageButtons + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsMessageButtons { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .readFirst + + case 2: return .unreadFirst + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsMessageButtons, into buf: inout [UInt8]) { + switch value { + + + case .readFirst: + writeInt(&buf, Int32(1)) + + + case .unreadFirst: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsMessageButtons_lift(_ buf: RustBuffer) throws -> MailSettingsMessageButtons { + return try FfiConverterTypeMailSettingsMessageButtons.lift(buf) +} + +public func FfiConverterTypeMailSettingsMessageButtons_lower(_ value: MailSettingsMessageButtons) -> RustBuffer { + return FfiConverterTypeMailSettingsMessageButtons.lower(value) +} + + +extension MailSettingsMessageButtons: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsNextMessageOnMove { + + case disabledExplicit + case disabledImplicit + case enabledExplicit +} + +public struct FfiConverterTypeMailSettingsNextMessageOnMove: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsNextMessageOnMove + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsNextMessageOnMove { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .disabledExplicit + + case 2: return .disabledImplicit + + case 3: return .enabledExplicit + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsNextMessageOnMove, into buf: inout [UInt8]) { + switch value { + + + case .disabledExplicit: + writeInt(&buf, Int32(1)) + + + case .disabledImplicit: + writeInt(&buf, Int32(2)) + + + case .enabledExplicit: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeMailSettingsNextMessageOnMove_lift(_ buf: RustBuffer) throws -> MailSettingsNextMessageOnMove { + return try FfiConverterTypeMailSettingsNextMessageOnMove.lift(buf) +} + +public func FfiConverterTypeMailSettingsNextMessageOnMove_lower(_ value: MailSettingsNextMessageOnMove) -> RustBuffer { + return FfiConverterTypeMailSettingsNextMessageOnMove.lower(value) +} + + +extension MailSettingsNextMessageOnMove: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsPgpScheme { + + case inline + case mime +} + +public struct FfiConverterTypeMailSettingsPGPScheme: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsPgpScheme + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsPgpScheme { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .inline + + case 2: return .mime + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsPgpScheme, into buf: inout [UInt8]) { + switch value { + + + case .inline: + writeInt(&buf, Int32(1)) + + + case .mime: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsPGPScheme_lift(_ buf: RustBuffer) throws -> MailSettingsPgpScheme { + return try FfiConverterTypeMailSettingsPGPScheme.lift(buf) +} + +public func FfiConverterTypeMailSettingsPGPScheme_lower(_ value: MailSettingsPgpScheme) -> RustBuffer { + return FfiConverterTypeMailSettingsPGPScheme.lower(value) +} + + +extension MailSettingsPgpScheme: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsPmSignature { + + case disabled + case enabled + case enabledLocked +} + +public struct FfiConverterTypeMailSettingsPMSignature: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsPmSignature + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsPmSignature { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .disabled + + case 2: return .enabled + + case 3: return .enabledLocked + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsPmSignature, into buf: inout [UInt8]) { + switch value { + + + case .disabled: + writeInt(&buf, Int32(1)) + + + case .enabled: + writeInt(&buf, Int32(2)) + + + case .enabledLocked: + writeInt(&buf, Int32(3)) + + } + } +} + + +public func FfiConverterTypeMailSettingsPMSignature_lift(_ buf: RustBuffer) throws -> MailSettingsPmSignature { + return try FfiConverterTypeMailSettingsPMSignature.lift(buf) +} + +public func FfiConverterTypeMailSettingsPMSignature_lower(_ value: MailSettingsPmSignature) -> RustBuffer { + return FfiConverterTypeMailSettingsPMSignature.lower(value) +} + + +extension MailSettingsPmSignature: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsShowImages { + + case doNotAutoLoad + case autoLoadRemote + case autoLoadEmbedded + case autoLoadBoth +} + +public struct FfiConverterTypeMailSettingsShowImages: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsShowImages + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsShowImages { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .doNotAutoLoad + + case 2: return .autoLoadRemote + + case 3: return .autoLoadEmbedded + + case 4: return .autoLoadBoth + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsShowImages, into buf: inout [UInt8]) { + switch value { + + + case .doNotAutoLoad: + writeInt(&buf, Int32(1)) + + + case .autoLoadRemote: + writeInt(&buf, Int32(2)) + + + case .autoLoadEmbedded: + writeInt(&buf, Int32(3)) + + + case .autoLoadBoth: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeMailSettingsShowImages_lift(_ buf: RustBuffer) throws -> MailSettingsShowImages { + return try FfiConverterTypeMailSettingsShowImages.lift(buf) +} + +public func FfiConverterTypeMailSettingsShowImages_lower(_ value: MailSettingsShowImages) -> RustBuffer { + return FfiConverterTypeMailSettingsShowImages.lower(value) +} + + +extension MailSettingsShowImages: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsShowMoved { + + case doNotKeep + case keepInDrafts + case keepInSent + case keepBoth +} + +public struct FfiConverterTypeMailSettingsShowMoved: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsShowMoved + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsShowMoved { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .doNotKeep + + case 2: return .keepInDrafts + + case 3: return .keepInSent + + case 4: return .keepBoth + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsShowMoved, into buf: inout [UInt8]) { + switch value { + + + case .doNotKeep: + writeInt(&buf, Int32(1)) + + + case .keepInDrafts: + writeInt(&buf, Int32(2)) + + + case .keepInSent: + writeInt(&buf, Int32(3)) + + + case .keepBoth: + writeInt(&buf, Int32(4)) + + } + } +} + + +public func FfiConverterTypeMailSettingsShowMoved_lift(_ buf: RustBuffer) throws -> MailSettingsShowMoved { + return try FfiConverterTypeMailSettingsShowMoved.lift(buf) +} + +public func FfiConverterTypeMailSettingsShowMoved_lower(_ value: MailSettingsShowMoved) -> RustBuffer { + return FfiConverterTypeMailSettingsShowMoved.lower(value) +} + + +extension MailSettingsShowMoved: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsSpamAction { + + case doNothing + case unsubscribeWithOneClick +} + +public struct FfiConverterTypeMailSettingsSpamAction: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsSpamAction + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsSpamAction { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .doNothing + + case 2: return .unsubscribeWithOneClick + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsSpamAction, into buf: inout [UInt8]) { + switch value { + + + case .doNothing: + writeInt(&buf, Int32(1)) + + + case .unsubscribeWithOneClick: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsSpamAction_lift(_ buf: RustBuffer) throws -> MailSettingsSpamAction { + return try FfiConverterTypeMailSettingsSpamAction.lift(buf) +} + +public func FfiConverterTypeMailSettingsSpamAction_lower(_ value: MailSettingsSpamAction) -> RustBuffer { + return FfiConverterTypeMailSettingsSpamAction.lower(value) +} + + +extension MailSettingsSpamAction: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsSwipeAction { + + case trash + case spam + case star + case archive + case markAsRead +} + +public struct FfiConverterTypeMailSettingsSwipeAction: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsSwipeAction + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsSwipeAction { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .trash + + case 2: return .spam + + case 3: return .star + + case 4: return .archive + + case 5: return .markAsRead + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsSwipeAction, into buf: inout [UInt8]) { + switch value { + + + case .trash: + writeInt(&buf, Int32(1)) + + + case .spam: + writeInt(&buf, Int32(2)) + + + case .star: + writeInt(&buf, Int32(3)) + + + case .archive: + writeInt(&buf, Int32(4)) + + + case .markAsRead: + writeInt(&buf, Int32(5)) + + } + } +} + + +public func FfiConverterTypeMailSettingsSwipeAction_lift(_ buf: RustBuffer) throws -> MailSettingsSwipeAction { + return try FfiConverterTypeMailSettingsSwipeAction.lift(buf) +} + +public func FfiConverterTypeMailSettingsSwipeAction_lower(_ value: MailSettingsSwipeAction) -> RustBuffer { + return FfiConverterTypeMailSettingsSwipeAction.lower(value) +} + + +extension MailSettingsSwipeAction: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsViewLayout { + + case column + case row +} + +public struct FfiConverterTypeMailSettingsViewLayout: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsViewLayout + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsViewLayout { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .column + + case 2: return .row + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsViewLayout, into buf: inout [UInt8]) { + switch value { + + + case .column: + writeInt(&buf, Int32(1)) + + + case .row: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsViewLayout_lift(_ buf: RustBuffer) throws -> MailSettingsViewLayout { + return try FfiConverterTypeMailSettingsViewLayout.lift(buf) +} + +public func FfiConverterTypeMailSettingsViewLayout_lower(_ value: MailSettingsViewLayout) -> RustBuffer { + return FfiConverterTypeMailSettingsViewLayout.lower(value) +} + + +extension MailSettingsViewLayout: Equatable, Hashable {} + + + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailSettingsViewMode { + + case conversations + case messages +} + +public struct FfiConverterTypeMailSettingsViewMode: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsViewMode + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailSettingsViewMode { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .conversations + + case 2: return .messages + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailSettingsViewMode, into buf: inout [UInt8]) { + switch value { + + + case .conversations: + writeInt(&buf, Int32(1)) + + + case .messages: + writeInt(&buf, Int32(2)) + + } + } +} + + +public func FfiConverterTypeMailSettingsViewMode_lift(_ buf: RustBuffer) throws -> MailSettingsViewMode { + return try FfiConverterTypeMailSettingsViewMode.lift(buf) +} + +public func FfiConverterTypeMailSettingsViewMode_lower(_ value: MailSettingsViewMode) -> RustBuffer { + return FfiConverterTypeMailSettingsViewMode.lower(value) +} + + +extension MailSettingsViewMode: Equatable, Hashable {} + + + +fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer { + typealias SwiftType = UInt32? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterUInt32.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterUInt32.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterString.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeMailSettingsMobileSettings: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsMobileSettings? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeMailSettingsMobileSettings.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeMailSettingsMobileSettings.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeMailSettingsNextMessageOnMove: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsNextMessageOnMove? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeMailSettingsNextMessageOnMove.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeMailSettingsNextMessageOnMove.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeMailSettingsSpamAction: FfiConverterRustBuffer { + typealias SwiftType = MailSettingsSpamAction? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeMailSettingsSpamAction.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeMailSettingsSpamAction.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeProtonBoolean: FfiConverterRustBuffer { + typealias SwiftType = ProtonBoolean? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeProtonBoolean.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeProtonBoolean.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeExternalId: FfiConverterRustBuffer { + typealias SwiftType = ExternalId? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeExternalId.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeExternalId.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeLabelId: FfiConverterRustBuffer { + typealias SwiftType = LabelId? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeLabelId.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeLabelId.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer { + typealias SwiftType = [String] + + public static func write(_ value: [String], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterString.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] { + let len: Int32 = try readInt(&buf) + var seq = [String]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterString.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeAttachmentMetadata: FfiConverterRustBuffer { + typealias SwiftType = [AttachmentMetadata] + + public static func write(_ value: [AttachmentMetadata], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeAttachmentMetadata.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AttachmentMetadata] { + let len: Int32 = try readInt(&buf) + var seq = [AttachmentMetadata]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeAttachmentMetadata.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeMessageAddress: FfiConverterRustBuffer { + typealias SwiftType = [MessageAddress] + + public static func write(_ value: [MessageAddress], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeMessageAddress.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [MessageAddress] { + let len: Int32 = try readInt(&buf) + var seq = [MessageAddress]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeMessageAddress.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeLabelId: FfiConverterRustBuffer { + typealias SwiftType = [LabelId] + + public static func write(_ value: [LabelId], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeLabelId.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LabelId] { + let len: Int32 = try readInt(&buf) + var seq = [LabelId]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeLabelId.read(from: &buf)) + } + return seq + } +} + + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias AddressId = String +public struct FfiConverterTypeAddressId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AddressId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: AddressId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> AddressId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: AddressId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeAddressId_lift(_ value: RustBuffer) throws -> AddressId { + return try FfiConverterTypeAddressId.lift(value) +} + +public func FfiConverterTypeAddressId_lower(_ value: AddressId) -> RustBuffer { + return FfiConverterTypeAddressId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias AttachmentId = String +public struct FfiConverterTypeAttachmentId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AttachmentId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: AttachmentId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> AttachmentId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: AttachmentId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeAttachmentId_lift(_ value: RustBuffer) throws -> AttachmentId { + return try FfiConverterTypeAttachmentId.lift(value) +} + +public func FfiConverterTypeAttachmentId_lower(_ value: AttachmentId) -> RustBuffer { + return FfiConverterTypeAttachmentId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias ConversationId = String +public struct FfiConverterTypeConversationId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ConversationId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: ConversationId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> ConversationId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: ConversationId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeConversationId_lift(_ value: RustBuffer) throws -> ConversationId { + return try FfiConverterTypeConversationId.lift(value) +} + +public func FfiConverterTypeConversationId_lower(_ value: ConversationId) -> RustBuffer { + return FfiConverterTypeConversationId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias ExternalId = String +public struct FfiConverterTypeExternalId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ExternalId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: ExternalId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> ExternalId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: ExternalId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeExternalId_lift(_ value: RustBuffer) throws -> ExternalId { + return try FfiConverterTypeExternalId.lift(value) +} + +public func FfiConverterTypeExternalId_lower(_ value: ExternalId) -> RustBuffer { + return FfiConverterTypeExternalId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias LabelId = String +public struct FfiConverterTypeLabelId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LabelId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: LabelId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> LabelId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: LabelId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeLabelId_lift(_ value: RustBuffer) throws -> LabelId { + return try FfiConverterTypeLabelId.lift(value) +} + +public func FfiConverterTypeLabelId_lower(_ value: LabelId) -> RustBuffer { + return FfiConverterTypeLabelId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias MessageId = String +public struct FfiConverterTypeMessageId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MessageId { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: MessageId, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> MessageId { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: MessageId) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeMessageId_lift(_ value: RustBuffer) throws -> MessageId { + return try FfiConverterTypeMessageId.lift(value) +} + +public func FfiConverterTypeMessageId_lower(_ value: MessageId) -> RustBuffer { + return FfiConverterTypeMessageId.lower(value) +} + + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_api_mail_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_common.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_common.swift new file mode 100644 index 0000000000..8a1254328a --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_common.swift @@ -0,0 +1,366 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_core_common_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_core_common_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_core_common_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_db.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_db.swift new file mode 100644 index 0000000000..cc3112e5fa --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_core_db.swift @@ -0,0 +1,366 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_core_db_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_core_db_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_core_db_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_common.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_common.swift new file mode 100644 index 0000000000..42cdbb0d01 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_common.swift @@ -0,0 +1,366 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_mail_common_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_mail_common_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_mail_common_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_db.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_db.swift new file mode 100644 index 0000000000..f830a43764 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_db.swift @@ -0,0 +1,1201 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_mail_db_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_mail_db_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterUInt32: FfiConverterPrimitive { + typealias FfiType = UInt32 + typealias SwiftType = UInt32 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { + typealias FfiType = UInt64 + typealias SwiftType = UInt64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterBool : FfiConverter { + typealias FfiType = Int8 + typealias SwiftType = Bool + + public static func lift(_ value: Int8) throws -> Bool { + return value != 0 + } + + public static func lower(_ value: Bool) -> Int8 { + return value ? 1 : 0 + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Bool, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + +public struct LocalConversation { + public var id: LocalConversationId + public var remoteId: ConversationId? + public var order: UInt64 + public var subject: String + public var senders: [MessageAddress] + public var recipients: [MessageAddress] + public var numMessages: UInt64 + public var numUnread: UInt64 + public var numAttachments: UInt64 + public var expirationTime: UInt64 + public var size: UInt64 + public var time: UInt64 + public var labels: [LocalConversationLabel]? + public var flagged: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: LocalConversationId, + remoteId: ConversationId?, + order: UInt64, + subject: String, + senders: [MessageAddress], + recipients: [MessageAddress], + numMessages: UInt64, + numUnread: UInt64, + numAttachments: UInt64, + expirationTime: UInt64, + size: UInt64, + time: UInt64, + labels: [LocalConversationLabel]?, + flagged: Bool) { + self.id = id + self.remoteId = remoteId + self.order = order + self.subject = subject + self.senders = senders + self.recipients = recipients + self.numMessages = numMessages + self.numUnread = numUnread + self.numAttachments = numAttachments + self.expirationTime = expirationTime + self.size = size + self.time = time + self.labels = labels + self.flagged = flagged + } +} + + +extension LocalConversation: Equatable, Hashable { + public static func ==(lhs: LocalConversation, rhs: LocalConversation) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.remoteId != rhs.remoteId { + return false + } + if lhs.order != rhs.order { + return false + } + if lhs.subject != rhs.subject { + return false + } + if lhs.senders != rhs.senders { + return false + } + if lhs.recipients != rhs.recipients { + return false + } + if lhs.numMessages != rhs.numMessages { + return false + } + if lhs.numUnread != rhs.numUnread { + return false + } + if lhs.numAttachments != rhs.numAttachments { + return false + } + if lhs.expirationTime != rhs.expirationTime { + return false + } + if lhs.size != rhs.size { + return false + } + if lhs.time != rhs.time { + return false + } + if lhs.labels != rhs.labels { + return false + } + if lhs.flagged != rhs.flagged { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(remoteId) + hasher.combine(order) + hasher.combine(subject) + hasher.combine(senders) + hasher.combine(recipients) + hasher.combine(numMessages) + hasher.combine(numUnread) + hasher.combine(numAttachments) + hasher.combine(expirationTime) + hasher.combine(size) + hasher.combine(time) + hasher.combine(labels) + hasher.combine(flagged) + } +} + + +public struct FfiConverterTypeLocalConversation: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalConversation { + return + try LocalConversation( + id: FfiConverterTypeLocalConversationId.read(from: &buf), + remoteId: FfiConverterOptionTypeConversationId.read(from: &buf), + order: FfiConverterUInt64.read(from: &buf), + subject: FfiConverterString.read(from: &buf), + senders: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + recipients: FfiConverterSequenceTypeMessageAddress.read(from: &buf), + numMessages: FfiConverterUInt64.read(from: &buf), + numUnread: FfiConverterUInt64.read(from: &buf), + numAttachments: FfiConverterUInt64.read(from: &buf), + expirationTime: FfiConverterUInt64.read(from: &buf), + size: FfiConverterUInt64.read(from: &buf), + time: FfiConverterUInt64.read(from: &buf), + labels: FfiConverterOptionSequenceTypeLocalConversationLabel.read(from: &buf), + flagged: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: LocalConversation, into buf: inout [UInt8]) { + FfiConverterTypeLocalConversationId.write(value.id, into: &buf) + FfiConverterOptionTypeConversationId.write(value.remoteId, into: &buf) + FfiConverterUInt64.write(value.order, into: &buf) + FfiConverterString.write(value.subject, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.senders, into: &buf) + FfiConverterSequenceTypeMessageAddress.write(value.recipients, into: &buf) + FfiConverterUInt64.write(value.numMessages, into: &buf) + FfiConverterUInt64.write(value.numUnread, into: &buf) + FfiConverterUInt64.write(value.numAttachments, into: &buf) + FfiConverterUInt64.write(value.expirationTime, into: &buf) + FfiConverterUInt64.write(value.size, into: &buf) + FfiConverterUInt64.write(value.time, into: &buf) + FfiConverterOptionSequenceTypeLocalConversationLabel.write(value.labels, into: &buf) + FfiConverterBool.write(value.flagged, into: &buf) + } +} + + +public func FfiConverterTypeLocalConversation_lift(_ buf: RustBuffer) throws -> LocalConversation { + return try FfiConverterTypeLocalConversation.lift(buf) +} + +public func FfiConverterTypeLocalConversation_lower(_ value: LocalConversation) -> RustBuffer { + return FfiConverterTypeLocalConversation.lower(value) +} + + +public struct LocalConversationLabel { + public var id: LocalLabelId + public var name: String + public var color: LabelColor + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: LocalLabelId, + name: String, + color: LabelColor) { + self.id = id + self.name = name + self.color = color + } +} + + +extension LocalConversationLabel: Equatable, Hashable { + public static func ==(lhs: LocalConversationLabel, rhs: LocalConversationLabel) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.color != rhs.color { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(name) + hasher.combine(color) + } +} + + +public struct FfiConverterTypeLocalConversationLabel: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalConversationLabel { + return + try LocalConversationLabel( + id: FfiConverterTypeLocalLabelId.read(from: &buf), + name: FfiConverterString.read(from: &buf), + color: FfiConverterTypeLabelColor.read(from: &buf) + ) + } + + public static func write(_ value: LocalConversationLabel, into buf: inout [UInt8]) { + FfiConverterTypeLocalLabelId.write(value.id, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterTypeLabelColor.write(value.color, into: &buf) + } +} + + +public func FfiConverterTypeLocalConversationLabel_lift(_ buf: RustBuffer) throws -> LocalConversationLabel { + return try FfiConverterTypeLocalConversationLabel.lift(buf) +} + +public func FfiConverterTypeLocalConversationLabel_lower(_ value: LocalConversationLabel) -> RustBuffer { + return FfiConverterTypeLocalConversationLabel.lower(value) +} + + +public struct LocalLabel { + public var id: LocalLabelId + public var rid: LabelId? + public var parentId: LocalLabelId? + public var name: String + public var path: String? + public var color: LabelColor + public var labelType: LabelType + public var order: UInt32 + public var notified: Bool + public var expanded: Bool + public var sticky: Bool + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: LocalLabelId, + rid: LabelId?, + parentId: LocalLabelId?, + name: String, + path: String?, + color: LabelColor, + labelType: LabelType, + order: UInt32, + notified: Bool, + expanded: Bool, + sticky: Bool) { + self.id = id + self.rid = rid + self.parentId = parentId + self.name = name + self.path = path + self.color = color + self.labelType = labelType + self.order = order + self.notified = notified + self.expanded = expanded + self.sticky = sticky + } +} + + +extension LocalLabel: Equatable, Hashable { + public static func ==(lhs: LocalLabel, rhs: LocalLabel) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.rid != rhs.rid { + return false + } + if lhs.parentId != rhs.parentId { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.path != rhs.path { + return false + } + if lhs.color != rhs.color { + return false + } + if lhs.labelType != rhs.labelType { + return false + } + if lhs.order != rhs.order { + return false + } + if lhs.notified != rhs.notified { + return false + } + if lhs.expanded != rhs.expanded { + return false + } + if lhs.sticky != rhs.sticky { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(rid) + hasher.combine(parentId) + hasher.combine(name) + hasher.combine(path) + hasher.combine(color) + hasher.combine(labelType) + hasher.combine(order) + hasher.combine(notified) + hasher.combine(expanded) + hasher.combine(sticky) + } +} + + +public struct FfiConverterTypeLocalLabel: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalLabel { + return + try LocalLabel( + id: FfiConverterTypeLocalLabelId.read(from: &buf), + rid: FfiConverterOptionTypeLabelId.read(from: &buf), + parentId: FfiConverterOptionTypeLocalLabelId.read(from: &buf), + name: FfiConverterString.read(from: &buf), + path: FfiConverterOptionString.read(from: &buf), + color: FfiConverterTypeLabelColor.read(from: &buf), + labelType: FfiConverterTypeLabelType.read(from: &buf), + order: FfiConverterUInt32.read(from: &buf), + notified: FfiConverterBool.read(from: &buf), + expanded: FfiConverterBool.read(from: &buf), + sticky: FfiConverterBool.read(from: &buf) + ) + } + + public static func write(_ value: LocalLabel, into buf: inout [UInt8]) { + FfiConverterTypeLocalLabelId.write(value.id, into: &buf) + FfiConverterOptionTypeLabelId.write(value.rid, into: &buf) + FfiConverterOptionTypeLocalLabelId.write(value.parentId, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.path, into: &buf) + FfiConverterTypeLabelColor.write(value.color, into: &buf) + FfiConverterTypeLabelType.write(value.labelType, into: &buf) + FfiConverterUInt32.write(value.order, into: &buf) + FfiConverterBool.write(value.notified, into: &buf) + FfiConverterBool.write(value.expanded, into: &buf) + FfiConverterBool.write(value.sticky, into: &buf) + } +} + + +public func FfiConverterTypeLocalLabel_lift(_ buf: RustBuffer) throws -> LocalLabel { + return try FfiConverterTypeLocalLabel.lift(buf) +} + +public func FfiConverterTypeLocalLabel_lower(_ value: LocalLabel) -> RustBuffer { + return FfiConverterTypeLocalLabel.lower(value) +} + + +public struct LocalLabelWithCount { + public var id: LocalLabelId + public var rid: LabelId? + public var parentId: LocalLabelId? + public var name: String + public var path: String? + public var color: LabelColor + public var labelType: LabelType + public var order: UInt32 + public var notified: Bool + public var expanded: Bool + public var sticky: Bool + public var totalCount: UInt64 + public var unreadCount: UInt64 + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + id: LocalLabelId, + rid: LabelId?, + parentId: LocalLabelId?, + name: String, + path: String?, + color: LabelColor, + labelType: LabelType, + order: UInt32, + notified: Bool, + expanded: Bool, + sticky: Bool, + totalCount: UInt64, + unreadCount: UInt64) { + self.id = id + self.rid = rid + self.parentId = parentId + self.name = name + self.path = path + self.color = color + self.labelType = labelType + self.order = order + self.notified = notified + self.expanded = expanded + self.sticky = sticky + self.totalCount = totalCount + self.unreadCount = unreadCount + } +} + + +extension LocalLabelWithCount: Equatable, Hashable { + public static func ==(lhs: LocalLabelWithCount, rhs: LocalLabelWithCount) -> Bool { + if lhs.id != rhs.id { + return false + } + if lhs.rid != rhs.rid { + return false + } + if lhs.parentId != rhs.parentId { + return false + } + if lhs.name != rhs.name { + return false + } + if lhs.path != rhs.path { + return false + } + if lhs.color != rhs.color { + return false + } + if lhs.labelType != rhs.labelType { + return false + } + if lhs.order != rhs.order { + return false + } + if lhs.notified != rhs.notified { + return false + } + if lhs.expanded != rhs.expanded { + return false + } + if lhs.sticky != rhs.sticky { + return false + } + if lhs.totalCount != rhs.totalCount { + return false + } + if lhs.unreadCount != rhs.unreadCount { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(rid) + hasher.combine(parentId) + hasher.combine(name) + hasher.combine(path) + hasher.combine(color) + hasher.combine(labelType) + hasher.combine(order) + hasher.combine(notified) + hasher.combine(expanded) + hasher.combine(sticky) + hasher.combine(totalCount) + hasher.combine(unreadCount) + } +} + + +public struct FfiConverterTypeLocalLabelWithCount: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalLabelWithCount { + return + try LocalLabelWithCount( + id: FfiConverterTypeLocalLabelId.read(from: &buf), + rid: FfiConverterOptionTypeLabelId.read(from: &buf), + parentId: FfiConverterOptionTypeLocalLabelId.read(from: &buf), + name: FfiConverterString.read(from: &buf), + path: FfiConverterOptionString.read(from: &buf), + color: FfiConverterTypeLabelColor.read(from: &buf), + labelType: FfiConverterTypeLabelType.read(from: &buf), + order: FfiConverterUInt32.read(from: &buf), + notified: FfiConverterBool.read(from: &buf), + expanded: FfiConverterBool.read(from: &buf), + sticky: FfiConverterBool.read(from: &buf), + totalCount: FfiConverterUInt64.read(from: &buf), + unreadCount: FfiConverterUInt64.read(from: &buf) + ) + } + + public static func write(_ value: LocalLabelWithCount, into buf: inout [UInt8]) { + FfiConverterTypeLocalLabelId.write(value.id, into: &buf) + FfiConverterOptionTypeLabelId.write(value.rid, into: &buf) + FfiConverterOptionTypeLocalLabelId.write(value.parentId, into: &buf) + FfiConverterString.write(value.name, into: &buf) + FfiConverterOptionString.write(value.path, into: &buf) + FfiConverterTypeLabelColor.write(value.color, into: &buf) + FfiConverterTypeLabelType.write(value.labelType, into: &buf) + FfiConverterUInt32.write(value.order, into: &buf) + FfiConverterBool.write(value.notified, into: &buf) + FfiConverterBool.write(value.expanded, into: &buf) + FfiConverterBool.write(value.sticky, into: &buf) + FfiConverterUInt64.write(value.totalCount, into: &buf) + FfiConverterUInt64.write(value.unreadCount, into: &buf) + } +} + + +public func FfiConverterTypeLocalLabelWithCount_lift(_ buf: RustBuffer) throws -> LocalLabelWithCount { + return try FfiConverterTypeLocalLabelWithCount.lift(buf) +} + +public func FfiConverterTypeLocalLabelWithCount_lower(_ value: LocalLabelWithCount) -> RustBuffer { + return FfiConverterTypeLocalLabelWithCount.lower(value) +} + +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterString.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionSequenceTypeLocalConversationLabel: FfiConverterRustBuffer { + typealias SwiftType = [LocalConversationLabel]? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterSequenceTypeLocalConversationLabel.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterSequenceTypeLocalConversationLabel.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeConversationId: FfiConverterRustBuffer { + typealias SwiftType = ConversationId? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeConversationId.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeConversationId.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeLabelId: FfiConverterRustBuffer { + typealias SwiftType = LabelId? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeLabelId.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeLabelId.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeLocalLabelId: FfiConverterRustBuffer { + typealias SwiftType = LocalLabelId? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeLocalLabelId.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeLocalLabelId.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterSequenceTypeLocalConversationLabel: FfiConverterRustBuffer { + typealias SwiftType = [LocalConversationLabel] + + public static func write(_ value: [LocalConversationLabel], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeLocalConversationLabel.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LocalConversationLabel] { + let len: Int32 = try readInt(&buf) + var seq = [LocalConversationLabel]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeLocalConversationLabel.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeMessageAddress: FfiConverterRustBuffer { + typealias SwiftType = [MessageAddress] + + public static func write(_ value: [MessageAddress], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeMessageAddress.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [MessageAddress] { + let len: Int32 = try readInt(&buf) + var seq = [MessageAddress]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeMessageAddress.read(from: &buf)) + } + return seq + } +} + + + + + + + + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias LabelColor = String +public struct FfiConverterTypeLabelColor: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LabelColor { + return try FfiConverterString.read(from: &buf) + } + + public static func write(_ value: LabelColor, into buf: inout [UInt8]) { + return FfiConverterString.write(value, into: &buf) + } + + public static func lift(_ value: RustBuffer) throws -> LabelColor { + return try FfiConverterString.lift(value) + } + + public static func lower(_ value: LabelColor) -> RustBuffer { + return FfiConverterString.lower(value) + } +} + + +public func FfiConverterTypeLabelColor_lift(_ value: RustBuffer) throws -> LabelColor { + return try FfiConverterTypeLabelColor.lift(value) +} + +public func FfiConverterTypeLabelColor_lower(_ value: LabelColor) -> RustBuffer { + return FfiConverterTypeLabelColor.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias LocalConversationId = UInt64 +public struct FfiConverterTypeLocalConversationId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalConversationId { + return try FfiConverterUInt64.read(from: &buf) + } + + public static func write(_ value: LocalConversationId, into buf: inout [UInt8]) { + return FfiConverterUInt64.write(value, into: &buf) + } + + public static func lift(_ value: UInt64) throws -> LocalConversationId { + return try FfiConverterUInt64.lift(value) + } + + public static func lower(_ value: LocalConversationId) -> UInt64 { + return FfiConverterUInt64.lower(value) + } +} + + +public func FfiConverterTypeLocalConversationId_lift(_ value: UInt64) throws -> LocalConversationId { + return try FfiConverterTypeLocalConversationId.lift(value) +} + +public func FfiConverterTypeLocalConversationId_lower(_ value: LocalConversationId) -> UInt64 { + return FfiConverterTypeLocalConversationId.lower(value) +} + + + +/** + * Typealias from the type name used in the UDL file to the builtin type. This + * is needed because the UDL type name is used in function/method signatures. + */ +public typealias LocalLabelId = UInt64 +public struct FfiConverterTypeLocalLabelId: FfiConverter { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocalLabelId { + return try FfiConverterUInt64.read(from: &buf) + } + + public static func write(_ value: LocalLabelId, into buf: inout [UInt8]) { + return FfiConverterUInt64.write(value, into: &buf) + } + + public static func lift(_ value: UInt64) throws -> LocalLabelId { + return try FfiConverterUInt64.lift(value) + } + + public static func lower(_ value: LocalLabelId) -> UInt64 { + return FfiConverterUInt64.lower(value) + } +} + + +public func FfiConverterTypeLocalLabelId_lift(_ value: UInt64) throws -> LocalLabelId { + return try FfiConverterTypeLocalLabelId.lift(value) +} + +public func FfiConverterTypeLocalLabelId_lower(_ value: LocalLabelId) -> UInt64 { + return FfiConverterTypeLocalLabelId.lower(value) +} + + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_mail_db_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_uniffi.swift b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_uniffi.swift new file mode 100644 index 0000000000..b61abd93a3 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi/proton_mail_uniffi.swift @@ -0,0 +1,3397 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! +import Foundation + +// Depending on the consumer's build setup, the low-level FFI code +// might be in a separate module, or it might be compiled inline into +// this module. This is a bit of light hackery to work with both. +#if canImport(proton_mail_uniffi_ffi) +import proton_mail_uniffi_ffi +#endif + +fileprivate extension RustBuffer { + // Allocate a new buffer, copying the contents of a `UInt8` array. + init(bytes: [UInt8]) { + let rbuf = bytes.withUnsafeBufferPointer { ptr in + RustBuffer.from(ptr) + } + self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data) + } + + static func from(_ ptr: UnsafeBufferPointer) -> RustBuffer { + try! rustCall { ffi_proton_mail_uniffi_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) } + } + + // Frees the buffer in place. + // The buffer must not be used after this is called. + func deallocate() { + try! rustCall { ffi_proton_mail_uniffi_rustbuffer_free(self, $0) } + } +} + +fileprivate extension ForeignBytes { + init(bufferPointer: UnsafeBufferPointer) { + self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress) + } +} + +// For every type used in the interface, we provide helper methods for conveniently +// lifting and lowering that type from C-compatible data, and for reading and writing +// values of that type in a buffer. + +// Helper classes/extensions that don't change. +// Someday, this will be in a library of its own. + +fileprivate extension Data { + init(rustBuffer: RustBuffer) { + // TODO: This copies the buffer. Can we read directly from a + // Rust buffer? + self.init(bytes: rustBuffer.data!, count: Int(rustBuffer.len)) + } +} + +// Define reader functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. +// +// With external types, one swift source file needs to be able to call the read +// method on another source file's FfiConverter, but then what visibility +// should Reader have? +// - If Reader is fileprivate, then this means the read() must also +// be fileprivate, which doesn't work with external types. +// - If Reader is internal/public, we'll get compile errors since both source +// files will try define the same type. +// +// Instead, the read() method and these helper functions input a tuple of data + +fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) { + (data: data, offset: 0) +} + +// Reads an integer at the current offset, in big-endian order, and advances +// the offset on success. Throws if reading the integer would move the +// offset past the end of the buffer. +fileprivate func readInt(_ reader: inout (data: Data, offset: Data.Index)) throws -> T { + let range = reader.offset...size + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + if T.self == UInt8.self { + let value = reader.data[reader.offset] + reader.offset += 1 + return value as! T + } + var value: T = 0 + let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)}) + reader.offset = range.upperBound + return value.bigEndian +} + +// Reads an arbitrary number of bytes, to be used to read +// raw bytes, this is useful when lifting strings +fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array { + let range = reader.offset..<(reader.offset+count) + guard reader.data.count >= range.upperBound else { + throw UniffiInternalError.bufferOverflow + } + var value = [UInt8](repeating: 0, count: count) + value.withUnsafeMutableBufferPointer({ buffer in + reader.data.copyBytes(to: buffer, from: range) + }) + reader.offset = range.upperBound + return value +} + +// Reads a float at the current offset. +fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float { + return Float(bitPattern: try readInt(&reader)) +} + +// Reads a float at the current offset. +fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double { + return Double(bitPattern: try readInt(&reader)) +} + +// Indicates if the offset has reached the end of the buffer. +fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool { + return reader.offset < reader.data.count +} + +// Define writer functionality. Normally this would be defined in a class or +// struct, but we use standalone functions instead in order to make external +// types work. See the above discussion on Readers for details. + +fileprivate func createWriter() -> [UInt8] { + return [] +} + +fileprivate func writeBytes(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 { + writer.append(contentsOf: byteArr) +} + +// Writes an integer in big-endian order. +// +// Warning: make sure what you are trying to write +// is in the correct type! +fileprivate func writeInt(_ writer: inout [UInt8], _ value: T) { + var value = value.bigEndian + withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) } +} + +fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) { + writeInt(&writer, value.bitPattern) +} + +fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) { + writeInt(&writer, value.bitPattern) +} + +// Protocol for types that transfer other types across the FFI. This is +// analogous go the Rust trait of the same name. +fileprivate protocol FfiConverter { + associatedtype FfiType + associatedtype SwiftType + + static func lift(_ value: FfiType) throws -> SwiftType + static func lower(_ value: SwiftType) -> FfiType + static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType + static func write(_ value: SwiftType, into buf: inout [UInt8]) +} + +// Types conforming to `Primitive` pass themselves directly over the FFI. +fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { } + +extension FfiConverterPrimitive { + public static func lift(_ value: FfiType) throws -> SwiftType { + return value + } + + public static func lower(_ value: SwiftType) -> FfiType { + return value + } +} + +// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`. +// Used for complex types where it's hard to write a custom lift/lower. +fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {} + +extension FfiConverterRustBuffer { + public static func lift(_ buf: RustBuffer) throws -> SwiftType { + var reader = createReader(data: Data(rustBuffer: buf)) + let value = try read(from: &reader) + if hasRemaining(reader) { + throw UniffiInternalError.incompleteData + } + buf.deallocate() + return value + } + + public static func lower(_ value: SwiftType) -> RustBuffer { + var writer = createWriter() + write(value, into: &writer) + return RustBuffer(bytes: writer) + } +} +// An error type for FFI errors. These errors occur at the UniFFI level, not +// the library level. +fileprivate enum UniffiInternalError: LocalizedError { + case bufferOverflow + case incompleteData + case unexpectedOptionalTag + case unexpectedEnumCase + case unexpectedNullPointer + case unexpectedRustCallStatusCode + case unexpectedRustCallError + case unexpectedStaleHandle + case rustPanic(_ message: String) + + public var errorDescription: String? { + switch self { + case .bufferOverflow: return "Reading the requested value would read past the end of the buffer" + case .incompleteData: return "The buffer still has data after lifting its containing value" + case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1" + case .unexpectedEnumCase: return "Raw enum value doesn't match any cases" + case .unexpectedNullPointer: return "Raw pointer value was null" + case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code" + case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified" + case .unexpectedStaleHandle: return "The object in the handle map has been dropped already" + case let .rustPanic(message): return message + } + } +} + +fileprivate let CALL_SUCCESS: Int8 = 0 +fileprivate let CALL_ERROR: Int8 = 1 +fileprivate let CALL_PANIC: Int8 = 2 +fileprivate let CALL_CANCELLED: Int8 = 3 + +fileprivate extension RustCallStatus { + init() { + self.init( + code: CALL_SUCCESS, + errorBuf: RustBuffer.init( + capacity: 0, + len: 0, + data: nil + ) + ) + } +} + +private func rustCall(_ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: nil) +} + +private func rustCallWithError( + _ errorHandler: @escaping (RustBuffer) throws -> Error, + _ callback: (UnsafeMutablePointer) -> T) throws -> T { + try makeRustCall(callback, errorHandler: errorHandler) +} + +private func makeRustCall( + _ callback: (UnsafeMutablePointer) -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) throws -> T { + uniffiEnsureInitialized() + var callStatus = RustCallStatus.init() + let returnedVal = callback(&callStatus) + try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler) + return returnedVal +} + +private func uniffiCheckCallStatus( + callStatus: RustCallStatus, + errorHandler: ((RustBuffer) throws -> Error)? +) throws { + switch callStatus.code { + case CALL_SUCCESS: + return + + case CALL_ERROR: + if let errorHandler = errorHandler { + throw try errorHandler(callStatus.errorBuf) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.unexpectedRustCallError + } + + case CALL_PANIC: + // When the rust code sees a panic, it tries to construct a RustBuffer + // with the message. But if that code panics, then it just sends back + // an empty buffer. + if callStatus.errorBuf.len > 0 { + throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf)) + } else { + callStatus.errorBuf.deallocate() + throw UniffiInternalError.rustPanic("Rust panic") + } + + case CALL_CANCELLED: + fatalError("Cancellation not supported yet") + + default: + throw UniffiInternalError.unexpectedRustCallStatusCode + } +} + +// Public interface members begin here. + + +fileprivate struct FfiConverterUInt64: FfiConverterPrimitive { + typealias FfiType = UInt64 + typealias SwiftType = UInt64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterInt64: FfiConverterPrimitive { + typealias FfiType = Int64 + typealias SwiftType = Int64 + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int64 { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Int64, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterBool : FfiConverter { + typealias FfiType = Int8 + typealias SwiftType = Bool + + public static func lift(_ value: Int8) throws -> Bool { + return value != 0 + } + + public static func lower(_ value: Bool) -> Int8 { + return value ? 1 : 0 + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool { + return try lift(readInt(&buf)) + } + + public static func write(_ value: Bool, into buf: inout [UInt8]) { + writeInt(&buf, lower(value)) + } +} + +fileprivate struct FfiConverterString: FfiConverter { + typealias SwiftType = String + typealias FfiType = RustBuffer + + public static func lift(_ value: RustBuffer) throws -> String { + defer { + value.deallocate() + } + if value.data == nil { + return String() + } + let bytes = UnsafeBufferPointer(start: value.data!, count: Int(value.len)) + return String(bytes: bytes, encoding: String.Encoding.utf8)! + } + + public static func lower(_ value: String) -> RustBuffer { + return value.utf8CString.withUnsafeBufferPointer { ptr in + // The swift string gives us int8_t, we want uint8_t. + ptr.withMemoryRebound(to: UInt8.self) { ptr in + // The swift string gives us a trailing null byte, we don't want it. + let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1)) + return RustBuffer.from(buf) + } + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String { + let len: Int32 = try readInt(&buf) + return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)! + } + + public static func write(_ value: String, into buf: inout [UInt8]) { + let len = Int32(value.utf8.count) + writeInt(&buf, len) + writeBytes(&buf, value.utf8) + } +} + + + + +/** + * Flow through the required steps to authenticate and login a user. + */ +public protocol LoginFlowProtocol : AnyObject { + + /** + * Check whether the login flow is awaiting 2FA input. + */ + func isAwaiting2fa() -> Bool + + /** + * Check whether the login flow has completed. + */ + func isLoggedIn() -> Bool + + /** + * Login with user and password. + */ + func login(email: String, password: String) async throws + + /** + * Submit 2FA totp code. + */ + func submitTotp(code: String) async throws + + /** + * When the flow is considered logged in, transform it into a MailUserContext. + */ + func toUserContext() throws -> MailUserContext + +} + +/** + * Flow through the required steps to authenticate and login a user. + */ +public class LoginFlow: + LoginFlowProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_loginflow(self.pointer, $0) } + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_loginflow(pointer, $0) } + } + + + + + + /** + * Check whether the login flow is awaiting 2FA input. + */ + public func isAwaiting2fa() -> Bool { + return try! FfiConverterBool.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_loginflow_is_awaiting_2fa(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Check whether the login flow has completed. + */ + public func isLoggedIn() -> Bool { + return try! FfiConverterBool.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_loginflow_is_logged_in(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Login with user and password. + */ + public func login(email: String, password: String) async throws { + return try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_proton_mail_uniffi_fn_method_loginflow_login( + self.uniffiClonePointer(), + FfiConverterString.lower(email), + FfiConverterString.lower(password) + ) + }, + pollFunc: ffi_proton_mail_uniffi_rust_future_poll_void, + completeFunc: ffi_proton_mail_uniffi_rust_future_complete_void, + freeFunc: ffi_proton_mail_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeLoginFlowError.lift + ) + } + + + /** + * Submit 2FA totp code. + */ + public func submitTotp(code: String) async throws { + return try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_proton_mail_uniffi_fn_method_loginflow_submit_totp( + self.uniffiClonePointer(), + FfiConverterString.lower(code) + ) + }, + pollFunc: ffi_proton_mail_uniffi_rust_future_poll_void, + completeFunc: ffi_proton_mail_uniffi_rust_future_complete_void, + freeFunc: ffi_proton_mail_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeLoginFlowError.lift + ) + } + + + /** + * When the flow is considered logged in, transform it into a MailUserContext. + */ + public func toUserContext() throws -> MailUserContext { + return try FfiConverterTypeMailUserContext.lift( + try + rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_method_loginflow_to_user_context(self.uniffiClonePointer(), $0 + ) +} + ) + } + +} + +public struct FfiConverterTypeLoginFlow: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = LoginFlow + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> LoginFlow { + return LoginFlow(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: LoginFlow) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LoginFlow { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: LoginFlow, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeLoginFlow_lift(_ pointer: UnsafeMutableRawPointer) throws -> LoginFlow { + return try FfiConverterTypeLoginFlow.lift(pointer) +} + +public func FfiConverterTypeLoginFlow_lower(_ value: LoginFlow) -> UnsafeMutableRawPointer { + return FfiConverterTypeLoginFlow.lower(value) +} + + + + +/** + * Mail context is the entry point for the application. + */ +public protocol MailContextProtocol : AnyObject { + + /** + * Check whether the network is connected/online. + */ + func isNetworkConnected() -> Bool + + /** + * Start new login flow. + */ + func newLoginFlow(cb: SessionCallback?) throws -> LoginFlow + + /** + * Externally notify the context that the network connection has changed. + */ + func setNetworkConnected(online: Bool) + + /** + * Retrieve the currently stored sessions. + */ + func storedSessions() throws -> [StoredSession] + + /** + * Create an user context from a stored session. + */ + func userContextFromSession(session: StoredSession, cb: SessionCallback?) throws -> MailUserContext + +} + +/** + * Mail context is the entry point for the application. + */ +public class MailContext: + MailContextProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_mailcontext(self.pointer, $0) } + } + /** + * Create a new mail context: + * * `session_dir`: Directory where the session db should be stored. + * * `user_dri`: Directory where the user db should be stored. + * * `log_dir:`: Directory where the log file should be stored. + * * `log_debug`: Whether to enable debug and trace logs + * * `key_chain`: KeyChain implementation + * * `network_callback`: Optional network status changed callback + */ + public convenience init(sessionDir: String, userDir: String, logDir: String, logDebug: Bool, keyChain: OsKeyChain, networkCallback: NetworkStatusChanged?) throws { + self.init(unsafeFromRawPointer: try rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_constructor_mailcontext_new( + FfiConverterString.lower(sessionDir), + FfiConverterString.lower(userDir), + FfiConverterString.lower(logDir), + FfiConverterBool.lower(logDebug), + FfiConverterCallbackInterfaceOsKeyChain.lower(keyChain), + FfiConverterOptionCallbackInterfaceNetworkStatusChanged.lower(networkCallback),$0) +}) + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_mailcontext(pointer, $0) } + } + + + + + + /** + * Check whether the network is connected/online. + */ + public func isNetworkConnected() -> Bool { + return try! FfiConverterBool.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailcontext_is_network_connected(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Start new login flow. + */ + public func newLoginFlow(cb: SessionCallback?) throws -> LoginFlow { + return try FfiConverterTypeLoginFlow.lift( + try + rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailcontext_new_login_flow(self.uniffiClonePointer(), + FfiConverterOptionCallbackInterfaceSessionCallback.lower(cb),$0 + ) +} + ) + } + /** + * Externally notify the context that the network connection has changed. + */ + public func setNetworkConnected(online: Bool) { + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailcontext_set_network_connected(self.uniffiClonePointer(), + FfiConverterBool.lower(online),$0 + ) +} + } + /** + * Retrieve the currently stored sessions. + */ + public func storedSessions() throws -> [StoredSession] { + return try FfiConverterSequenceTypeStoredSession.lift( + try + rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailcontext_stored_sessions(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Create an user context from a stored session. + */ + public func userContextFromSession(session: StoredSession, cb: SessionCallback?) throws -> MailUserContext { + return try FfiConverterTypeMailUserContext.lift( + try + rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailcontext_user_context_from_session(self.uniffiClonePointer(), + FfiConverterTypeStoredSession.lower(session), + FfiConverterOptionCallbackInterfaceSessionCallback.lower(cb),$0 + ) +} + ) + } + +} + +public struct FfiConverterTypeMailContext: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = MailContext + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MailContext { + return MailContext(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: MailContext) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailContext { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: MailContext, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeMailContext_lift(_ pointer: UnsafeMutableRawPointer) throws -> MailContext { + return try FfiConverterTypeMailContext.lift(pointer) +} + +public func FfiConverterTypeMailContext_lower(_ value: MailContext) -> UnsafeMutableRawPointer { + return FfiConverterTypeMailContext.lower(value) +} + + + + +public protocol MailUserContextProtocol : AnyObject { + + /** + * Initialize the user context. Should be called at least once. + */ + func initialize(cb: MailUserContextInitializationCallback) async throws + + /** + * Log out a session. + */ + func logout() async throws + + func mailSettings() throws -> MailSettings + + /** + * Poll Event loop and apply events. + */ + func pollEvents() async throws + +} + +public class MailUserContext: + MailUserContextProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_mailusercontext(self.pointer, $0) } + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_mailusercontext(pointer, $0) } + } + + + + + + /** + * Initialize the user context. Should be called at least once. + */ + public func initialize(cb: MailUserContextInitializationCallback) async throws { + return try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_proton_mail_uniffi_fn_method_mailusercontext_initialize( + self.uniffiClonePointer(), + FfiConverterCallbackInterfaceMailUserContextInitializationCallback.lower(cb) + ) + }, + pollFunc: ffi_proton_mail_uniffi_rust_future_poll_void, + completeFunc: ffi_proton_mail_uniffi_rust_future_complete_void, + freeFunc: ffi_proton_mail_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeMailContextError.lift + ) + } + + + /** + * Log out a session. + */ + public func logout() async throws { + return try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_proton_mail_uniffi_fn_method_mailusercontext_logout( + self.uniffiClonePointer() + ) + }, + pollFunc: ffi_proton_mail_uniffi_rust_future_poll_void, + completeFunc: ffi_proton_mail_uniffi_rust_future_complete_void, + freeFunc: ffi_proton_mail_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeMailContextError.lift + ) + } + + + public func mailSettings() throws -> MailSettings { + return try FfiConverterTypeMailSettings_lift( + try + rustCallWithError(FfiConverterTypeMailContextError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailusercontext_mail_settings(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Poll Event loop and apply events. + */ + public func pollEvents() async throws { + return try await uniffiRustCallAsync( + rustFutureFunc: { + uniffi_proton_mail_uniffi_fn_method_mailusercontext_poll_events( + self.uniffiClonePointer() + ) + }, + pollFunc: ffi_proton_mail_uniffi_rust_future_poll_void, + completeFunc: ffi_proton_mail_uniffi_rust_future_complete_void, + freeFunc: ffi_proton_mail_uniffi_rust_future_free_void, + liftFunc: { $0 }, + errorHandler: FfiConverterTypeEventLoopError.lift + ) + } + + + +} + +public struct FfiConverterTypeMailUserContext: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = MailUserContext + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MailUserContext { + return MailUserContext(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: MailUserContext) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailUserContext { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: MailUserContext, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeMailUserContext_lift(_ pointer: UnsafeMutableRawPointer) throws -> MailUserContext { + return try FfiConverterTypeMailUserContext.lift(pointer) +} + +public func FfiConverterTypeMailUserContext_lower(_ value: MailUserContext) -> UnsafeMutableRawPointer { + return FfiConverterTypeMailUserContext.lower(value) +} + + + + +public protocol MailboxProtocol : AnyObject { + + /** + * Return the currently selected label. + */ + func activeLabel() -> LocalLabel + + /** + * Get conversations for the current selected label. + */ + func conversations(count: Int64) throws -> [LocalConversation] + + /** + * Get list of ordered labels by type. + */ + func labelsByType(labelType: LabelType) throws -> [LocalLabelWithCount] + + /** + * Create a query observer for conversations for the currently selected label. If you + * change the mailbox label with `switch_label` you need to create a new instance. + */ + func newConversationObservedQuery(limit: Int64, cb: MailboxLiveQueryUpdatedCallback) -> MailboxConversationLiveQuery + + /** + * Create a query observer on labels of type Folder. + */ + func newFolderLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery + + /** + * Create a query observer on labels of type Label. + */ + func newLabelLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery + + /** + * Create a query observer on labels of type System. + */ + func newSystemLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery + + /** + * Switch the mailbox to another label. + */ + func switchLabel(labelId: UInt64, messageCount: Int64, cb: MailboxBackgroundResult?) throws + +} + +public class Mailbox: + MailboxProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_mailbox(self.pointer, $0) } + } + public convenience init(ctx: MailUserContext) throws { + self.init(unsafeFromRawPointer: try rustCallWithError(FfiConverterTypeMailboxError.lift) { + uniffi_proton_mail_uniffi_fn_constructor_mailbox_new( + FfiConverterTypeMailUserContext.lower(ctx),$0) +}) + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_mailbox(pointer, $0) } + } + + + + + + /** + * Return the currently selected label. + */ + public func activeLabel() -> LocalLabel { + return try! FfiConverterTypeLocalLabel_lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailbox_active_label(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Get conversations for the current selected label. + */ + public func conversations(count: Int64) throws -> [LocalConversation] { + return try FfiConverterSequenceTypeLocalConversation.lift( + try + rustCallWithError(FfiConverterTypeMailboxError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailbox_conversations(self.uniffiClonePointer(), + FfiConverterInt64.lower(count),$0 + ) +} + ) + } + /** + * Get list of ordered labels by type. + */ + public func labelsByType(labelType: LabelType) throws -> [LocalLabelWithCount] { + return try FfiConverterSequenceTypeLocalLabelWithCount.lift( + try + rustCallWithError(FfiConverterTypeMailboxError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailbox_labels_by_type(self.uniffiClonePointer(), + FfiConverterTypeLabelType_lower(labelType),$0 + ) +} + ) + } + /** + * Create a query observer for conversations for the currently selected label. If you + * change the mailbox label with `switch_label` you need to create a new instance. + */ + public func newConversationObservedQuery(limit: Int64, cb: MailboxLiveQueryUpdatedCallback) -> MailboxConversationLiveQuery { + return try! FfiConverterTypeMailboxConversationLiveQuery.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailbox_new_conversation_observed_query(self.uniffiClonePointer(), + FfiConverterInt64.lower(limit), + FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.lower(cb),$0 + ) +} + ) + } + /** + * Create a query observer on labels of type Folder. + */ + public func newFolderLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery { + return try! FfiConverterTypeMailboxLabelsLiveQuery.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailbox_new_folder_labels_observed_query(self.uniffiClonePointer(), + FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.lower(cb),$0 + ) +} + ) + } + /** + * Create a query observer on labels of type Label. + */ + public func newLabelLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery { + return try! FfiConverterTypeMailboxLabelsLiveQuery.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailbox_new_label_labels_observed_query(self.uniffiClonePointer(), + FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.lower(cb),$0 + ) +} + ) + } + /** + * Create a query observer on labels of type System. + */ + public func newSystemLabelsObservedQuery(cb: MailboxLiveQueryUpdatedCallback) -> MailboxLabelsLiveQuery { + return try! FfiConverterTypeMailboxLabelsLiveQuery.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailbox_new_system_labels_observed_query(self.uniffiClonePointer(), + FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.lower(cb),$0 + ) +} + ) + } + /** + * Switch the mailbox to another label. + */ + public func switchLabel(labelId: UInt64, messageCount: Int64, cb: MailboxBackgroundResult?) throws { + try + rustCallWithError(FfiConverterTypeMailboxError.lift) { + uniffi_proton_mail_uniffi_fn_method_mailbox_switch_label(self.uniffiClonePointer(), + FfiConverterUInt64.lower(labelId), + FfiConverterInt64.lower(messageCount), + FfiConverterOptionCallbackInterfaceMailboxBackgroundResult.lower(cb),$0 + ) +} + } + +} + +public struct FfiConverterTypeMailbox: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = Mailbox + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> Mailbox { + return Mailbox(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: Mailbox) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Mailbox { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: Mailbox, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeMailbox_lift(_ pointer: UnsafeMutableRawPointer) throws -> Mailbox { + return try FfiConverterTypeMailbox.lift(pointer) +} + +public func FfiConverterTypeMailbox_lower(_ value: Mailbox) -> UnsafeMutableRawPointer { + return FfiConverterTypeMailbox.lower(value) +} + + + + +/** + * Observable query. + */ +public protocol MailboxConversationLiveQueryProtocol : AnyObject { + + /** + * Terminate the observer for this query and stop receiving updates. + */ + func disconnect() + + /** + * Get the latest value for this Query. + */ + func value() -> [LocalConversation] + +} + +/** + * Observable query. + */ +public class MailboxConversationLiveQuery: + MailboxConversationLiveQueryProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_mailboxconversationlivequery(self.pointer, $0) } + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_mailboxconversationlivequery(pointer, $0) } + } + + + + + + /** + * Terminate the observer for this query and stop receiving updates. + */ + public func disconnect() { + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_disconnect(self.uniffiClonePointer(), $0 + ) +} + } + /** + * Get the latest value for this Query. + */ + public func value() -> [LocalConversation] { + return try! FfiConverterSequenceTypeLocalConversation.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_value(self.uniffiClonePointer(), $0 + ) +} + ) + } + +} + +public struct FfiConverterTypeMailboxConversationLiveQuery: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = MailboxConversationLiveQuery + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MailboxConversationLiveQuery { + return MailboxConversationLiveQuery(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: MailboxConversationLiveQuery) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailboxConversationLiveQuery { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: MailboxConversationLiveQuery, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeMailboxConversationLiveQuery_lift(_ pointer: UnsafeMutableRawPointer) throws -> MailboxConversationLiveQuery { + return try FfiConverterTypeMailboxConversationLiveQuery.lift(pointer) +} + +public func FfiConverterTypeMailboxConversationLiveQuery_lower(_ value: MailboxConversationLiveQuery) -> UnsafeMutableRawPointer { + return FfiConverterTypeMailboxConversationLiveQuery.lower(value) +} + + + + +/** + * Observable query. + */ +public protocol MailboxLabelsLiveQueryProtocol : AnyObject { + + /** + * Terminate the observer for this query and stop receiving updates. + */ + func disconnect() + + /** + * Get the latest value for this Query. + */ + func value() -> [LocalLabelWithCount] + +} + +/** + * Observable query. + */ +public class MailboxLabelsLiveQuery: + MailboxLabelsLiveQueryProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_mailboxlabelslivequery(self.pointer, $0) } + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_mailboxlabelslivequery(pointer, $0) } + } + + + + + + /** + * Terminate the observer for this query and stop receiving updates. + */ + public func disconnect() { + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_disconnect(self.uniffiClonePointer(), $0 + ) +} + } + /** + * Get the latest value for this Query. + */ + public func value() -> [LocalLabelWithCount] { + return try! FfiConverterSequenceTypeLocalLabelWithCount.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_value(self.uniffiClonePointer(), $0 + ) +} + ) + } + +} + +public struct FfiConverterTypeMailboxLabelsLiveQuery: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = MailboxLabelsLiveQuery + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> MailboxLabelsLiveQuery { + return MailboxLabelsLiveQuery(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: MailboxLabelsLiveQuery) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailboxLabelsLiveQuery { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: MailboxLabelsLiveQuery, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeMailboxLabelsLiveQuery_lift(_ pointer: UnsafeMutableRawPointer) throws -> MailboxLabelsLiveQuery { + return try FfiConverterTypeMailboxLabelsLiveQuery.lift(pointer) +} + +public func FfiConverterTypeMailboxLabelsLiveQuery_lower(_ value: MailboxLabelsLiveQuery) -> UnsafeMutableRawPointer { + return FfiConverterTypeMailboxLabelsLiveQuery.lower(value) +} + + + + +/** + * Represents a session that has been stored on the device. + */ +public protocol StoredSessionProtocol : AnyObject { + + /** + * Get the session's email. + */ + func email() -> String + + /** + * Get the session's account name (if any). + */ + func name() -> String? + + /** + * Get the session id. + */ + func sessionId() -> Uid + + /** + * Get the session's user id. + */ + func userId() -> UserId + +} + +/** + * Represents a session that has been stored on the device. + */ +public class StoredSession: + StoredSessionProtocol { + fileprivate let pointer: UnsafeMutableRawPointer + + // TODO: We'd like this to be `private` but for Swifty reasons, + // we can't implement `FfiConverter` without making this `required` and we can't + // make it `required` without making it `public`. + required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) { + self.pointer = pointer + } + + public func uniffiClonePointer() -> UnsafeMutableRawPointer { + return try! rustCall { uniffi_proton_mail_uniffi_fn_clone_storedsession(self.pointer, $0) } + } + + deinit { + try! rustCall { uniffi_proton_mail_uniffi_fn_free_storedsession(pointer, $0) } + } + + + + + + /** + * Get the session's email. + */ + public func email() -> String { + return try! FfiConverterString.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_storedsession_email(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Get the session's account name (if any). + */ + public func name() -> String? { + return try! FfiConverterOptionString.lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_storedsession_name(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Get the session id. + */ + public func sessionId() -> Uid { + return try! FfiConverterTypeUid_lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_storedsession_session_id(self.uniffiClonePointer(), $0 + ) +} + ) + } + /** + * Get the session's user id. + */ + public func userId() -> UserId { + return try! FfiConverterTypeUserId_lift( + try! + rustCall() { + + uniffi_proton_mail_uniffi_fn_method_storedsession_user_id(self.uniffiClonePointer(), $0 + ) +} + ) + } + +} + +public struct FfiConverterTypeStoredSession: FfiConverter { + + typealias FfiType = UnsafeMutableRawPointer + typealias SwiftType = StoredSession + + public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> StoredSession { + return StoredSession(unsafeFromRawPointer: pointer) + } + + public static func lower(_ value: StoredSession) -> UnsafeMutableRawPointer { + return value.uniffiClonePointer() + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StoredSession { + let v: UInt64 = try readInt(&buf) + // The Rust code won't compile if a pointer won't fit in a UInt64. + // We have to go via `UInt` because that's the thing that's the size of a pointer. + let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v)) + if (ptr == nil) { + throw UniffiInternalError.unexpectedNullPointer + } + return try lift(ptr!) + } + + public static func write(_ value: StoredSession, into buf: inout [UInt8]) { + // This fiddling is because `Int` is the thing that's the same size as a pointer. + // The Rust code won't compile if a pointer won't fit in a `UInt64`. + writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value))))) + } +} + + +public func FfiConverterTypeStoredSession_lift(_ pointer: UnsafeMutableRawPointer) throws -> StoredSession { + return try FfiConverterTypeStoredSession.lift(pointer) +} + +public func FfiConverterTypeStoredSession_lower(_ value: StoredSession) -> UnsafeMutableRawPointer { + return FfiConverterTypeStoredSession.lower(value) +} + + +/** + * Result of [`locate_blockquote`], `before` contains the parent message and `after` contains + * the remainder. + */ +public struct LocateBlockquoteResult { + public var before: String + public var after: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init( + before: String, + after: String) { + self.before = before + self.after = after + } +} + + +extension LocateBlockquoteResult: Equatable, Hashable { + public static func ==(lhs: LocateBlockquoteResult, rhs: LocateBlockquoteResult) -> Bool { + if lhs.before != rhs.before { + return false + } + if lhs.after != rhs.after { + return false + } + return true + } + + public func hash(into hasher: inout Hasher) { + hasher.combine(before) + hasher.combine(after) + } +} + + +public struct FfiConverterTypeLocateBlockquoteResult: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LocateBlockquoteResult { + return + try LocateBlockquoteResult( + before: FfiConverterString.read(from: &buf), + after: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: LocateBlockquoteResult, into buf: inout [UInt8]) { + FfiConverterString.write(value.before, into: &buf) + FfiConverterString.write(value.after, into: &buf) + } +} + + +public func FfiConverterTypeLocateBlockquoteResult_lift(_ buf: RustBuffer) throws -> LocateBlockquoteResult { + return try FfiConverterTypeLocateBlockquoteResult.lift(buf) +} + +public func FfiConverterTypeLocateBlockquoteResult_lower(_ value: LocateBlockquoteResult) -> RustBuffer { + return FfiConverterTypeLocateBlockquoteResult.lower(value) +} + + +public enum EventLoopError { + + + + case StoreRead(message: String) + + case StoreWrite(message: String) + + case Provider(message: String) + + case Subscriber(message: String) + + case Other(message: String) + + + fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { + return try FfiConverterTypeEventLoopError.lift(error) + } +} + + +public struct FfiConverterTypeEventLoopError: FfiConverterRustBuffer { + typealias SwiftType = EventLoopError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EventLoopError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .StoreRead( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .StoreWrite( + message: try FfiConverterString.read(from: &buf) + ) + + case 3: return .Provider( + message: try FfiConverterString.read(from: &buf) + ) + + case 4: return .Subscriber( + message: try FfiConverterString.read(from: &buf) + ) + + case 5: return .Other( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: EventLoopError, into buf: inout [UInt8]) { + switch value { + + + + + case .StoreRead(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .StoreWrite(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + case .Provider(_ /* message is ignored*/): + writeInt(&buf, Int32(3)) + case .Subscriber(_ /* message is ignored*/): + writeInt(&buf, Int32(4)) + case .Other(_ /* message is ignored*/): + writeInt(&buf, Int32(5)) + + + } + } +} + + +extension EventLoopError: Equatable, Hashable {} + +extension EventLoopError: Error { } + + +public enum LoginFlowError { + + + + case Request(message: String) + + case ServerProof(message: String) + + case Unsupported2Fa(message: String) + + case HumanVerificationRequired(message: String) + + case SrpProof(message: String) + + case InvalidState(message: String) + + + fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { + return try FfiConverterTypeLoginFlowError.lift(error) + } +} + + +public struct FfiConverterTypeLoginFlowError: FfiConverterRustBuffer { + typealias SwiftType = LoginFlowError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LoginFlowError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .Request( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .ServerProof( + message: try FfiConverterString.read(from: &buf) + ) + + case 3: return .Unsupported2Fa( + message: try FfiConverterString.read(from: &buf) + ) + + case 4: return .HumanVerificationRequired( + message: try FfiConverterString.read(from: &buf) + ) + + case 5: return .SrpProof( + message: try FfiConverterString.read(from: &buf) + ) + + case 6: return .InvalidState( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: LoginFlowError, into buf: inout [UInt8]) { + switch value { + + + + + case .Request(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .ServerProof(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + case .Unsupported2Fa(_ /* message is ignored*/): + writeInt(&buf, Int32(3)) + case .HumanVerificationRequired(_ /* message is ignored*/): + writeInt(&buf, Int32(4)) + case .SrpProof(_ /* message is ignored*/): + writeInt(&buf, Int32(5)) + case .InvalidState(_ /* message is ignored*/): + writeInt(&buf, Int32(6)) + + + } + } +} + + +extension LoginFlowError: Equatable, Hashable {} + +extension LoginFlowError: Error { } + + +public enum MailContextError { + + + + case Db(message: String) + + case Crypto(message: String) + + case KeyChain(message: String) + + case Io(message: String) + + case DbMigration(message: String) + + case KeyChainHasNoKey(message: String) + + case Http(message: String) + + case EventLoop(message: String) + + case Other(message: String) + + + fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { + return try FfiConverterTypeMailContextError.lift(error) + } +} + + +public struct FfiConverterTypeMailContextError: FfiConverterRustBuffer { + typealias SwiftType = MailContextError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailContextError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .Db( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .Crypto( + message: try FfiConverterString.read(from: &buf) + ) + + case 3: return .KeyChain( + message: try FfiConverterString.read(from: &buf) + ) + + case 4: return .Io( + message: try FfiConverterString.read(from: &buf) + ) + + case 5: return .DbMigration( + message: try FfiConverterString.read(from: &buf) + ) + + case 6: return .KeyChainHasNoKey( + message: try FfiConverterString.read(from: &buf) + ) + + case 7: return .Http( + message: try FfiConverterString.read(from: &buf) + ) + + case 8: return .EventLoop( + message: try FfiConverterString.read(from: &buf) + ) + + case 9: return .Other( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailContextError, into buf: inout [UInt8]) { + switch value { + + + + + case .Db(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .Crypto(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + case .KeyChain(_ /* message is ignored*/): + writeInt(&buf, Int32(3)) + case .Io(_ /* message is ignored*/): + writeInt(&buf, Int32(4)) + case .DbMigration(_ /* message is ignored*/): + writeInt(&buf, Int32(5)) + case .KeyChainHasNoKey(_ /* message is ignored*/): + writeInt(&buf, Int32(6)) + case .Http(_ /* message is ignored*/): + writeInt(&buf, Int32(7)) + case .EventLoop(_ /* message is ignored*/): + writeInt(&buf, Int32(8)) + case .Other(_ /* message is ignored*/): + writeInt(&buf, Int32(9)) + + + } + } +} + + +extension MailContextError: Equatable, Hashable {} + +extension MailContextError: Error { } + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum MailUserContextInitializationStage { + + case user + case mailSettings + case addresses + case events + case labels + case counters + case conversation + case finished +} + +public struct FfiConverterTypeMailUserContextInitializationStage: FfiConverterRustBuffer { + typealias SwiftType = MailUserContextInitializationStage + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailUserContextInitializationStage { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .user + + case 2: return .mailSettings + + case 3: return .addresses + + case 4: return .events + + case 5: return .labels + + case 6: return .counters + + case 7: return .conversation + + case 8: return .finished + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailUserContextInitializationStage, into buf: inout [UInt8]) { + switch value { + + + case .user: + writeInt(&buf, Int32(1)) + + + case .mailSettings: + writeInt(&buf, Int32(2)) + + + case .addresses: + writeInt(&buf, Int32(3)) + + + case .events: + writeInt(&buf, Int32(4)) + + + case .labels: + writeInt(&buf, Int32(5)) + + + case .counters: + writeInt(&buf, Int32(6)) + + + case .conversation: + writeInt(&buf, Int32(7)) + + + case .finished: + writeInt(&buf, Int32(8)) + + } + } +} + + +public func FfiConverterTypeMailUserContextInitializationStage_lift(_ buf: RustBuffer) throws -> MailUserContextInitializationStage { + return try FfiConverterTypeMailUserContextInitializationStage.lift(buf) +} + +public func FfiConverterTypeMailUserContextInitializationStage_lower(_ value: MailUserContextInitializationStage) -> RustBuffer { + return FfiConverterTypeMailUserContextInitializationStage.lower(value) +} + + +extension MailUserContextInitializationStage: Equatable, Hashable {} + + + + +public enum MailboxError { + + + + case LabelNotFound(message: String) + + case RemoteLabelNotFound(message: String) + + case LabelDoesNotHaveRemoteId(message: String) + + case Context(message: String) + + + fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { + return try FfiConverterTypeMailboxError.lift(error) + } +} + + +public struct FfiConverterTypeMailboxError: FfiConverterRustBuffer { + typealias SwiftType = MailboxError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MailboxError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .LabelNotFound( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .RemoteLabelNotFound( + message: try FfiConverterString.read(from: &buf) + ) + + case 3: return .LabelDoesNotHaveRemoteId( + message: try FfiConverterString.read(from: &buf) + ) + + case 4: return .Context( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: MailboxError, into buf: inout [UInt8]) { + switch value { + + + + + case .LabelNotFound(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .RemoteLabelNotFound(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + case .LabelDoesNotHaveRemoteId(_ /* message is ignored*/): + writeInt(&buf, Int32(3)) + case .Context(_ /* message is ignored*/): + writeInt(&buf, Int32(4)) + + + } + } +} + + +extension MailboxError: Equatable, Hashable {} + +extension MailboxError: Error { } + + +/** + * Errors for keychain operations. + */ +public enum OsKeyChainError { + + + + /** + * OS operation failed. + */ + case Os(message: String) + + /** + * Some other error occurred. + */ + case Other(message: String) + + + fileprivate static func uniffiErrorHandler(_ error: RustBuffer) throws -> Error { + return try FfiConverterTypeOSKeyChainError.lift(error) + } +} + + +public struct FfiConverterTypeOSKeyChainError: FfiConverterRustBuffer { + typealias SwiftType = OsKeyChainError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OsKeyChainError { + let variant: Int32 = try readInt(&buf) + switch variant { + + + + + case 1: return .Os( + message: try FfiConverterString.read(from: &buf) + ) + + case 2: return .Other( + message: try FfiConverterString.read(from: &buf) + ) + + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: OsKeyChainError, into buf: inout [UInt8]) { + switch value { + + + + + case .Os(_ /* message is ignored*/): + writeInt(&buf, Int32(1)) + case .Other(_ /* message is ignored*/): + writeInt(&buf, Int32(2)) + + + } + } +} + + +extension OsKeyChainError: Equatable, Hashable {} + +extension OsKeyChainError: Error { } + +// Note that we don't yet support `indirect` for enums. +// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion. +public enum SessionError { + + case db + case crypto + case keyChain + case keyChainHasNoKey + case other + case http +} + +public struct FfiConverterTypeSessionError: FfiConverterRustBuffer { + typealias SwiftType = SessionError + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SessionError { + let variant: Int32 = try readInt(&buf) + switch variant { + + case 1: return .db + + case 2: return .crypto + + case 3: return .keyChain + + case 4: return .keyChainHasNoKey + + case 5: return .other + + case 6: return .http + + default: throw UniffiInternalError.unexpectedEnumCase + } + } + + public static func write(_ value: SessionError, into buf: inout [UInt8]) { + switch value { + + + case .db: + writeInt(&buf, Int32(1)) + + + case .crypto: + writeInt(&buf, Int32(2)) + + + case .keyChain: + writeInt(&buf, Int32(3)) + + + case .keyChainHasNoKey: + writeInt(&buf, Int32(4)) + + + case .other: + writeInt(&buf, Int32(5)) + + + case .http: + writeInt(&buf, Int32(6)) + + } + } +} + + +public func FfiConverterTypeSessionError_lift(_ buf: RustBuffer) throws -> SessionError { + return try FfiConverterTypeSessionError.lift(buf) +} + +public func FfiConverterTypeSessionError_lower(_ value: SessionError) -> RustBuffer { + return FfiConverterTypeSessionError.lower(value) +} + + +extension SessionError: Equatable, Hashable {} + + + + + + +/** + * Callback for initialization progress. + */ +public protocol MailUserContextInitializationCallback : AnyObject { + + /** + * Called when a given initialization stage is entered. + */ + func onStage(stage: MailUserContextInitializationStage) + +} + +fileprivate extension NSLock { + func withLock(f: () throws -> T) rethrows -> T { + self.lock() + defer { self.unlock() } + return try f() + } +} + +fileprivate typealias UniFFICallbackHandle = UInt64 +fileprivate class UniFFICallbackHandleMap { + private var leftMap: [UniFFICallbackHandle: T] = [:] + private var counter: [UniFFICallbackHandle: UInt64] = [:] + private var rightMap: [ObjectIdentifier: UniFFICallbackHandle] = [:] + + private let lock = NSLock() + private var currentHandle: UniFFICallbackHandle = 1 + private let stride: UniFFICallbackHandle = 1 + + func insert(obj: T) -> UniFFICallbackHandle { + lock.withLock { + let id = ObjectIdentifier(obj as AnyObject) + let handle = rightMap[id] ?? { + currentHandle += stride + let handle = currentHandle + leftMap[handle] = obj + rightMap[id] = handle + return handle + }() + counter[handle] = (counter[handle] ?? 0) + 1 + return handle + } + } + + func get(handle: UniFFICallbackHandle) -> T? { + lock.withLock { + leftMap[handle] + } + } + + func delete(handle: UniFFICallbackHandle) { + remove(handle: handle) + } + + @discardableResult + func remove(handle: UniFFICallbackHandle) -> T? { + lock.withLock { + defer { counter[handle] = (counter[handle] ?? 1) - 1 } + guard counter[handle] == 1 else { return leftMap[handle] } + let obj = leftMap.removeValue(forKey: handle) + if let obj = obj { + rightMap.removeValue(forKey: ObjectIdentifier(obj as AnyObject)) + } + return obj + } + } +} + +// Magic number for the Rust proxy to call using the same mechanism as every other method, +// to free the callback once it's dropped by Rust. +private let IDX_CALLBACK_FREE: Int32 = 0 +// Callback return codes +private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0 +private let UNIFFI_CALLBACK_ERROR: Int32 = 1 +private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2 + +// Declaration and FfiConverters for MailUserContextInitializationCallback Callback Interface + +fileprivate let uniffiCallbackHandlerMailUserContextInitializationCallback : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeOnStage(_ swiftCallbackInterface: MailUserContextInitializationCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + swiftCallbackInterface.onStage( + stage: try FfiConverterTypeMailUserContextInitializationStage.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceMailUserContextInitializationCallback.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceMailUserContextInitializationCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnStage(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitMailUserContextInitializationCallback() { + uniffi_proton_mail_uniffi_fn_init_callback_mailusercontextinitializationcallback(uniffiCallbackHandlerMailUserContextInitializationCallback) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceMailUserContextInitializationCallback { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceMailUserContextInitializationCallback : FfiConverter { + typealias SwiftType = MailUserContextInitializationCallback + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + + + +/** + * Callback for operations that get scheduled in the background and return no result. + */ +public protocol MailboxBackgroundResult : AnyObject { + + func onBackgroundResult(error: MailboxError?) + +} + + + +// Declaration and FfiConverters for MailboxBackgroundResult Callback Interface + +fileprivate let uniffiCallbackHandlerMailboxBackgroundResult : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeOnBackgroundResult(_ swiftCallbackInterface: MailboxBackgroundResult, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + swiftCallbackInterface.onBackgroundResult( + error: try FfiConverterOptionTypeMailboxError.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceMailboxBackgroundResult.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceMailboxBackgroundResult.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnBackgroundResult(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitMailboxBackgroundResult() { + uniffi_proton_mail_uniffi_fn_init_callback_mailboxbackgroundresult(uniffiCallbackHandlerMailboxBackgroundResult) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceMailboxBackgroundResult { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceMailboxBackgroundResult : FfiConverter { + typealias SwiftType = MailboxBackgroundResult + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + + + +/** + * Callback for a labels view data change. + */ +public protocol MailboxLiveQueryUpdatedCallback : AnyObject { + + func onUpdated() + +} + + + +// Declaration and FfiConverters for MailboxLiveQueryUpdatedCallback Callback Interface + +fileprivate let uniffiCallbackHandlerMailboxLiveQueryUpdatedCallback : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeOnUpdated(_ swiftCallbackInterface: MailboxLiveQueryUpdatedCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + func makeCall() throws -> Int32 { + swiftCallbackInterface.onUpdated( + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnUpdated(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitMailboxLiveQueryUpdatedCallback() { + uniffi_proton_mail_uniffi_fn_init_callback_mailboxlivequeryupdatedcallback(uniffiCallbackHandlerMailboxLiveQueryUpdatedCallback) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceMailboxLiveQueryUpdatedCallback : FfiConverter { + typealias SwiftType = MailboxLiveQueryUpdatedCallback + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + + + +/** + * Callback when the network status in the context has changed. + */ +public protocol NetworkStatusChanged : AnyObject { + + func onNetworkStatusChanged(online: Bool) + +} + + + +// Declaration and FfiConverters for NetworkStatusChanged Callback Interface + +fileprivate let uniffiCallbackHandlerNetworkStatusChanged : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeOnNetworkStatusChanged(_ swiftCallbackInterface: NetworkStatusChanged, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + swiftCallbackInterface.onNetworkStatusChanged( + online: try FfiConverterBool.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceNetworkStatusChanged.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceNetworkStatusChanged.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnNetworkStatusChanged(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitNetworkStatusChanged() { + uniffi_proton_mail_uniffi_fn_init_callback_networkstatuschanged(uniffiCallbackHandlerNetworkStatusChanged) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceNetworkStatusChanged { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceNetworkStatusChanged : FfiConverter { + typealias SwiftType = NetworkStatusChanged + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + + + +/** + * Interface for accessing the OS keychain. + */ +public protocol OsKeyChain : AnyObject { + + /** + * Store the secret in the keychain. + */ + func store(key: String) throws + + /** + * Remote the secret from the keychain. + */ + func delete() throws + + /** + * Retrieve the secret from the keychain. + */ + func get() throws -> String? + +} + + + +// Declaration and FfiConverters for OsKeyChain Callback Interface + +fileprivate let uniffiCallbackHandlerOSKeyChain : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeStore(_ swiftCallbackInterface: OsKeyChain, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + try swiftCallbackInterface.store( + key: try FfiConverterString.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + do { + return try makeCall() + } catch let error as OsKeyChainError { + out_buf.pointee = FfiConverterTypeOSKeyChainError.lower(error) + return UNIFFI_CALLBACK_ERROR + } + } + + func invokeDelete(_ swiftCallbackInterface: OsKeyChain, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + func makeCall() throws -> Int32 { + try swiftCallbackInterface.delete( + ) + return UNIFFI_CALLBACK_SUCCESS + } + do { + return try makeCall() + } catch let error as OsKeyChainError { + out_buf.pointee = FfiConverterTypeOSKeyChainError.lower(error) + return UNIFFI_CALLBACK_ERROR + } + } + + func invokeGet(_ swiftCallbackInterface: OsKeyChain, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + func makeCall() throws -> Int32 { + let result = try swiftCallbackInterface.get( + ) + var writer = [UInt8]() + FfiConverterOptionString.write(result, into: &writer) + out_buf.pointee = RustBuffer(bytes: writer) + return UNIFFI_CALLBACK_SUCCESS + } + do { + return try makeCall() + } catch let error as OsKeyChainError { + out_buf.pointee = FfiConverterTypeOSKeyChainError.lower(error) + return UNIFFI_CALLBACK_ERROR + } + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceOsKeyChain.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceOsKeyChain.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeStore(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + case 2: + guard let cb = FfiConverterCallbackInterfaceOsKeyChain.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeDelete(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + case 3: + guard let cb = FfiConverterCallbackInterfaceOsKeyChain.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeGet(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitOSKeyChain() { + uniffi_proton_mail_uniffi_fn_init_callback_oskeychain(uniffiCallbackHandlerOSKeyChain) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceOsKeyChain { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceOsKeyChain : FfiConverter { + typealias SwiftType = OsKeyChain + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + + + + +public protocol SessionCallback : AnyObject { + + /** + * Triggered when the session has been refreshed. + */ + func onSessionRefresh() + + /** + * Triggered when the session has been destroyed. + */ + func onSessionDeleted() + + /** + * Triggered when the refresh operation fails. + */ + func onRefreshFailed(e: SessionError) + + /** + * Triggers if any error occurs while persisting the session data. + */ + func onError(err: SessionError) + +} + + + +// Declaration and FfiConverters for SessionCallback Callback Interface + +fileprivate let uniffiCallbackHandlerSessionCallback : ForeignCallback = + { (handle: UniFFICallbackHandle, method: Int32, argsData: UnsafePointer, argsLen: Int32, out_buf: UnsafeMutablePointer) -> Int32 in + + + func invokeOnSessionRefresh(_ swiftCallbackInterface: SessionCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + func makeCall() throws -> Int32 { + swiftCallbackInterface.onSessionRefresh( + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + func invokeOnSessionDeleted(_ swiftCallbackInterface: SessionCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + func makeCall() throws -> Int32 { + swiftCallbackInterface.onSessionDeleted( + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + func invokeOnRefreshFailed(_ swiftCallbackInterface: SessionCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + swiftCallbackInterface.onRefreshFailed( + e: try FfiConverterTypeSessionError.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + func invokeOnError(_ swiftCallbackInterface: SessionCallback, _ argsData: UnsafePointer, _ argsLen: Int32, _ out_buf: UnsafeMutablePointer) throws -> Int32 { + var reader = createReader(data: Data(bytes: argsData, count: Int(argsLen))) + func makeCall() throws -> Int32 { + swiftCallbackInterface.onError( + err: try FfiConverterTypeSessionError.read(from: &reader) + ) + return UNIFFI_CALLBACK_SUCCESS + } + return try makeCall() + } + + + switch method { + case IDX_CALLBACK_FREE: + FfiConverterCallbackInterfaceSessionCallback.handleMap.remove(handle: handle) + // Successful return + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_SUCCESS + case 1: + guard let cb = FfiConverterCallbackInterfaceSessionCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnSessionRefresh(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + case 2: + guard let cb = FfiConverterCallbackInterfaceSessionCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnSessionDeleted(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + case 3: + guard let cb = FfiConverterCallbackInterfaceSessionCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnRefreshFailed(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + case 4: + guard let cb = FfiConverterCallbackInterfaceSessionCallback.handleMap.get(handle: handle) else { + out_buf.pointee = FfiConverterString.lower("No callback in handlemap; this is a Uniffi bug") + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + do { + return try invokeOnError(cb, argsData, argsLen, out_buf) + } catch let error { + out_buf.pointee = FfiConverterString.lower(String(describing: error)) + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } + + // This should never happen, because an out of bounds method index won't + // ever be used. Once we can catch errors, we should return an InternalError. + // https://github.com/mozilla/uniffi-rs/issues/351 + default: + // An unexpected error happened. + // See docs of ForeignCallback in `uniffi_core/src/ffi/foreigncallbacks.rs` + return UNIFFI_CALLBACK_UNEXPECTED_ERROR + } +} + +private func uniffiCallbackInitSessionCallback() { + uniffi_proton_mail_uniffi_fn_init_callback_sessioncallback(uniffiCallbackHandlerSessionCallback) +} + +// FfiConverter protocol for callback interfaces +fileprivate struct FfiConverterCallbackInterfaceSessionCallback { + fileprivate static var handleMap = UniFFICallbackHandleMap() +} + +extension FfiConverterCallbackInterfaceSessionCallback : FfiConverter { + typealias SwiftType = SessionCallback + // We can use Handle as the FfiType because it's a typealias to UInt64 + typealias FfiType = UniFFICallbackHandle + + public static func lift(_ handle: UniFFICallbackHandle) throws -> SwiftType { + guard let callback = handleMap.get(handle: handle) else { + throw UniffiInternalError.unexpectedStaleHandle + } + return callback + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + let handle: UniFFICallbackHandle = try readInt(&buf) + return try lift(handle) + } + + public static func lower(_ v: SwiftType) -> UniFFICallbackHandle { + return handleMap.insert(obj: v) + } + + public static func write(_ v: SwiftType, into buf: inout [UInt8]) { + writeInt(&buf, lower(v)) + } +} + +fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer { + typealias SwiftType = String? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterString.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterString.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionTypeMailboxError: FfiConverterRustBuffer { + typealias SwiftType = MailboxError? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterTypeMailboxError.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterTypeMailboxError.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionCallbackInterfaceMailboxBackgroundResult: FfiConverterRustBuffer { + typealias SwiftType = MailboxBackgroundResult? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterCallbackInterfaceMailboxBackgroundResult.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterCallbackInterfaceMailboxBackgroundResult.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionCallbackInterfaceNetworkStatusChanged: FfiConverterRustBuffer { + typealias SwiftType = NetworkStatusChanged? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterCallbackInterfaceNetworkStatusChanged.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterCallbackInterfaceNetworkStatusChanged.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterOptionCallbackInterfaceSessionCallback: FfiConverterRustBuffer { + typealias SwiftType = SessionCallback? + + public static func write(_ value: SwiftType, into buf: inout [UInt8]) { + guard let value = value else { + writeInt(&buf, Int8(0)) + return + } + writeInt(&buf, Int8(1)) + FfiConverterCallbackInterfaceSessionCallback.write(value, into: &buf) + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { + switch try readInt(&buf) as Int8 { + case 0: return nil + case 1: return try FfiConverterCallbackInterfaceSessionCallback.read(from: &buf) + default: throw UniffiInternalError.unexpectedOptionalTag + } + } +} + +fileprivate struct FfiConverterSequenceTypeStoredSession: FfiConverterRustBuffer { + typealias SwiftType = [StoredSession] + + public static func write(_ value: [StoredSession], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeStoredSession.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [StoredSession] { + let len: Int32 = try readInt(&buf) + var seq = [StoredSession]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeStoredSession.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeLocalConversation: FfiConverterRustBuffer { + typealias SwiftType = [LocalConversation] + + public static func write(_ value: [LocalConversation], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeLocalConversation.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LocalConversation] { + let len: Int32 = try readInt(&buf) + var seq = [LocalConversation]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeLocalConversation.read(from: &buf)) + } + return seq + } +} + +fileprivate struct FfiConverterSequenceTypeLocalLabelWithCount: FfiConverterRustBuffer { + typealias SwiftType = [LocalLabelWithCount] + + public static func write(_ value: [LocalLabelWithCount], into buf: inout [UInt8]) { + let len = Int32(value.count) + writeInt(&buf, len) + for item in value { + FfiConverterTypeLocalLabelWithCount.write(item, into: &buf) + } + } + + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LocalLabelWithCount] { + let len: Int32 = try readInt(&buf) + var seq = [LocalLabelWithCount]() + seq.reserveCapacity(Int(len)) + for _ in 0 ..< len { + seq.append(try FfiConverterTypeLocalLabelWithCount.read(from: &buf)) + } + return seq + } +} + + + + + + + + + + + + + + +private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0 +private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1 + +fileprivate func uniffiRustCallAsync( + rustFutureFunc: () -> UnsafeMutableRawPointer, + pollFunc: (UnsafeMutableRawPointer, @escaping UniFfiRustFutureContinuation, UnsafeMutableRawPointer) -> (), + completeFunc: (UnsafeMutableRawPointer, UnsafeMutablePointer) -> F, + freeFunc: (UnsafeMutableRawPointer) -> (), + liftFunc: (F) throws -> T, + errorHandler: ((RustBuffer) throws -> Error)? +) async throws -> T { + // Make sure to call uniffiEnsureInitialized() since future creation doesn't have a + // RustCallStatus param, so doesn't use makeRustCall() + uniffiEnsureInitialized() + let rustFuture = rustFutureFunc() + defer { + freeFunc(rustFuture) + } + var pollResult: Int8; + repeat { + pollResult = await withUnsafeContinuation { + pollFunc(rustFuture, uniffiFutureContinuationCallback, ContinuationHolder($0).toOpaque()) + } + } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY + + return try liftFunc(makeRustCall( + { completeFunc(rustFuture, $0) }, + errorHandler: errorHandler + )) +} + +// Callback handlers for an async calls. These are invoked by Rust when the future is ready. They +// lift the return value or error and resume the suspended function. +fileprivate func uniffiFutureContinuationCallback(ptr: UnsafeMutableRawPointer, pollResult: Int8) { + ContinuationHolder.fromOpaque(ptr).resume(pollResult) +} + +// Wraps UnsafeContinuation in a class so that we can use reference counting when passing it across +// the FFI +fileprivate class ContinuationHolder { + let continuation: UnsafeContinuation + + init(_ continuation: UnsafeContinuation) { + self.continuation = continuation + } + + func resume(_ pollResult: Int8) { + self.continuation.resume(returning: pollResult) + } + + func toOpaque() -> UnsafeMutableRawPointer { + return Unmanaged.passRetained(self).toOpaque() + } + + static func fromOpaque(_ ptr: UnsafeRawPointer) -> ContinuationHolder { + return Unmanaged.fromOpaque(ptr).takeRetainedValue() + } +} +/** + * Try to locate the eventual blockquote present in the document no matter the expeditor of the mail + * + * Return the HTML content split at the blockquote start + */ +public func locateBlockquote(input: String) -> LocateBlockquoteResult { + return try! FfiConverterTypeLocateBlockquoteResult.lift( + try! rustCall() { + uniffi_proton_mail_uniffi_fn_func_locate_blockquote( + FfiConverterString.lower(input),$0) +} + ) +} + +private enum InitializationResult { + case ok + case contractVersionMismatch + case apiChecksumMismatch +} +// Use a global variables to perform the versioning checks. Swift ensures that +// the code inside is only computed once. +private var initializationResult: InitializationResult { + // Get the bindings contract version from our ComponentInterface + let bindings_contract_version = 25 + // Get the scaffolding contract version by calling the into the dylib + let scaffolding_contract_version = ffi_proton_mail_uniffi_uniffi_contract_version() + if bindings_contract_version != scaffolding_contract_version { + return InitializationResult.contractVersionMismatch + } + if (uniffi_proton_mail_uniffi_checksum_func_locate_blockquote() != 29543) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_loginflow_is_awaiting_2fa() != 64412) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_loginflow_is_logged_in() != 61848) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_loginflow_login() != 50659) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_loginflow_submit_totp() != 48562) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_loginflow_to_user_context() != 42390) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailcontext_is_network_connected() != 54737) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailcontext_new_login_flow() != 32444) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailcontext_set_network_connected() != 63730) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailcontext_stored_sessions() != 9719) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailcontext_user_context_from_session() != 26654) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailusercontext_initialize() != 2924) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailusercontext_logout() != 6964) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailusercontext_mail_settings() != 2198) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailusercontext_poll_events() != 48163) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_active_label() != 25561) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_conversations() != 2938) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_labels_by_type() != 7546) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_new_conversation_observed_query() != 38696) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_new_folder_labels_observed_query() != 42829) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_new_label_labels_observed_query() != 12506) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_new_system_labels_observed_query() != 42726) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailbox_switch_label() != 8729) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_disconnect() != 55329) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_value() != 13397) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_disconnect() != 10818) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_value() != 49083) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_storedsession_email() != 51014) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_storedsession_name() != 41920) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_storedsession_session_id() != 57786) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_storedsession_user_id() != 38174) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_constructor_mailcontext_new() != 58113) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_constructor_mailbox_new() != 51794) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailusercontextinitializationcallback_on_stage() != 37416) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxbackgroundresult_on_background_result() != 30392) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_mailboxlivequeryupdatedcallback_on_updated() != 11286) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_networkstatuschanged_on_network_status_changed() != 26288) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_oskeychain_store() != 30020) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_oskeychain_delete() != 50445) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_oskeychain_get() != 45002) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_refresh() != 10137) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_deleted() != 36025) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_refresh_failed() != 22240) { + return InitializationResult.apiChecksumMismatch + } + if (uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_error() != 19595) { + return InitializationResult.apiChecksumMismatch + } + + uniffiCallbackInitMailUserContextInitializationCallback() + uniffiCallbackInitMailboxBackgroundResult() + uniffiCallbackInitMailboxLiveQueryUpdatedCallback() + uniffiCallbackInitNetworkStatusChanged() + uniffiCallbackInitOSKeyChain() + uniffiCallbackInitSessionCallback() + return InitializationResult.ok +} + +private func uniffiEnsureInitialized() { + switch initializationResult { + case .ok: + break + case .contractVersionMismatch: + fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project") + case .apiChecksumMismatch: + fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project") + } +} \ No newline at end of file diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h new file mode 100644 index 0000000000..94f63cc69a --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_api_core_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_core_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_core_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_api_core_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_api_core_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_api_core_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_api_core_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_api_core_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_api_core_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_api_core_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_api_core_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_api_core_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_api_core_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_api_core_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_api_core_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_api_core_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h new file mode 100644 index 0000000000..c51639ec4f --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_api_mail_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_mail_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_mail_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_api_mail_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_api_mail_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_api_mail_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_api_mail_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_api_mail_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_api_mail_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_api_mail_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_api_mail_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_api_mail_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_api_mail_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_api_mail_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_api_mail_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_api_mail_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h new file mode 100644 index 0000000000..498da8df66 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_core_common_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_common_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_common_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_core_common_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_core_common_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_core_common_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_core_common_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_core_common_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_core_common_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_core_common_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_core_common_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_core_common_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_core_common_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_core_common_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_core_common_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_core_common_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h new file mode 100644 index 0000000000..a47764a014 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_core_db_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_db_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_db_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_core_db_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_core_db_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_core_db_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_core_db_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_core_db_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_core_db_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_core_db_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_core_db_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_core_db_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_core_db_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_core_db_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_core_db_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_core_db_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h new file mode 100644 index 0000000000..0ce757e93c --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_mail_common_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_common_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_common_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_common_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_common_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_common_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_common_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_common_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_common_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_common_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_common_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_common_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_common_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_common_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_common_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_mail_common_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h new file mode 100644 index 0000000000..7f81d3fb86 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_mail_db_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_db_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_db_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_db_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_db_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_db_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_db_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_db_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_db_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_db_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_db_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_db_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_db_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_db_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_db_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_mail_db_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h new file mode 100644 index 0000000000..59e03ccfa4 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h @@ -0,0 +1,407 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_loginflow(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_loginflow(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_loginflow_is_awaiting_2fa(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_loginflow_is_logged_in(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_login(void*_Nonnull ptr, RustBuffer email, RustBuffer password +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_submit_totp(void*_Nonnull ptr, RustBuffer code +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_to_user_context(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailcontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailcontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_constructor_mailcontext_new(RustBuffer session_dir, RustBuffer user_dir, RustBuffer log_dir, int8_t log_debug, uint64_t key_chain, RustBuffer network_callback, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_mailcontext_is_network_connected(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailcontext_new_login_flow(void*_Nonnull ptr, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailcontext_set_network_connected(void*_Nonnull ptr, int8_t online, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailcontext_stored_sessions(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailcontext_user_context_from_session(void*_Nonnull ptr, void*_Nonnull session, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailusercontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailusercontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_initialize(void*_Nonnull ptr, uint64_t cb +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_logout(void*_Nonnull ptr +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailusercontext_mail_settings(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_poll_events(void*_Nonnull ptr +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailbox(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailbox(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_constructor_mailbox_new(void*_Nonnull ctx, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_active_label(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_conversations(void*_Nonnull ptr, int64_t count, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_labels_by_type(void*_Nonnull ptr, RustBuffer label_type, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_conversation_observed_query(void*_Nonnull ptr, int64_t limit, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_folder_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_label_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_system_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailbox_switch_label(void*_Nonnull ptr, uint64_t label_id, int64_t message_count, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailboxconversationlivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailboxconversationlivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_disconnect(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_value(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailboxlabelslivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailboxlabelslivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_disconnect(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_value(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_storedsession(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_storedsession(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_email(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_name(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_session_id(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_user_id(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailusercontextinitializationcallback(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailboxbackgroundresult(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailboxlivequeryupdatedcallback(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_networkstatuschanged(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_oskeychain(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_sessioncallback(ForeignCallback _Nonnull handle +); +RustBuffer uniffi_proton_mail_uniffi_fn_func_locate_blockquote(RustBuffer input, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_uniffi_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_uniffi_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_uniffi_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_uniffi_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_uniffi_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_uniffi_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_uniffi_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_uniffi_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_uniffi_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_uniffi_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_uniffi_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_uniffi_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint16_t uniffi_proton_mail_uniffi_checksum_func_locate_blockquote(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_is_awaiting_2fa(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_is_logged_in(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_login(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_submit_totp(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_to_user_context(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_is_network_connected(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_new_login_flow(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_set_network_connected(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_stored_sessions(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_user_context_from_session(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_initialize(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_logout(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_mail_settings(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_poll_events(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_active_label(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_conversations(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_labels_by_type(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_conversation_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_folder_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_label_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_system_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_switch_label(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_disconnect(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_value(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_disconnect(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_value(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_email(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_name(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_session_id(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_user_id(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_constructor_mailcontext_new(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_constructor_mailbox_new(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontextinitializationcallback_on_stage(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxbackgroundresult_on_background_result(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlivequeryupdatedcallback_on_updated(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_networkstatuschanged_on_network_status_changed(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_store(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_delete(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_get(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_refresh(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_deleted(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_refresh_failed(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_error(void + +); +uint32_t ffi_proton_mail_uniffi_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Modules/module.modulemap b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Modules/module.modulemap new file mode 100644 index 0000000000..558be47bd5 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/Modules/module.modulemap @@ -0,0 +1,10 @@ +framework module proton_mail_uniffi_ffi { + header "proton_api_coreFFI.h" + header "proton_api_mailFFI.h" + header "proton_core_commonFFI.h" + header "proton_core_dbFFI.h" + header "proton_mail_commonFFI.h" + header "proton_mail_dbFFI.h" + header "proton_mail_uniffiFFI.h" + export * +} diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi new file mode 100644 index 0000000000..7e08bc09b2 Binary files /dev/null and b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi differ diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h new file mode 100644 index 0000000000..94f63cc69a --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_coreFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_api_core_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_core_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_core_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_api_core_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_api_core_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_api_core_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_api_core_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_api_core_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_api_core_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_api_core_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_api_core_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_api_core_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_api_core_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_api_core_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_api_core_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_core_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_core_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_api_core_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_api_core_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h new file mode 100644 index 0000000000..c51639ec4f --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_api_mailFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_api_mail_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_mail_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_api_mail_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_api_mail_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_api_mail_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_api_mail_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_api_mail_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_api_mail_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_api_mail_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_api_mail_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_api_mail_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_api_mail_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_api_mail_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_api_mail_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_api_mail_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_api_mail_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_api_mail_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_api_mail_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_api_mail_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h new file mode 100644 index 0000000000..498da8df66 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_commonFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_core_common_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_common_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_common_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_core_common_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_core_common_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_core_common_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_core_common_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_core_common_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_core_common_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_core_common_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_core_common_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_core_common_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_core_common_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_core_common_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_core_common_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_common_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_common_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_core_common_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_core_common_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h new file mode 100644 index 0000000000..a47764a014 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_core_dbFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_core_db_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_db_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_core_db_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_core_db_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_core_db_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_core_db_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_core_db_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_core_db_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_core_db_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_core_db_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_core_db_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_core_db_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_core_db_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_core_db_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_core_db_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_core_db_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_core_db_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_core_db_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_core_db_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h new file mode 100644 index 0000000000..0ce757e93c --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_commonFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_mail_common_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_common_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_common_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_common_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_common_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_common_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_common_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_common_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_common_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_common_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_common_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_common_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_common_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_common_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_common_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_common_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_common_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_common_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_mail_common_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h new file mode 100644 index 0000000000..7f81d3fb86 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_dbFFI.h @@ -0,0 +1,169 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +RustBuffer ffi_proton_mail_db_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_db_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_db_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_db_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_db_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_db_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_db_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_db_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_db_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_db_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_db_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_db_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_db_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_db_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_db_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_db_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_db_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_db_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint32_t ffi_proton_mail_db_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h new file mode 100644 index 0000000000..59e03ccfa4 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Headers/proton_mail_uniffiFFI.h @@ -0,0 +1,407 @@ +// This file was autogenerated by some hot garbage in the `uniffi` crate. +// Trust me, you don't want to mess with it! + +#pragma once + +#include +#include +#include + +// The following structs are used to implement the lowest level +// of the FFI, and thus useful to multiple uniffied crates. +// We ensure they are declared exactly once, with a header guard, UNIFFI_SHARED_H. +#ifdef UNIFFI_SHARED_H + // We also try to prevent mixing versions of shared uniffi header structs. + // If you add anything to the #else block, you must increment the version suffix in UNIFFI_SHARED_HEADER_V4 + #ifndef UNIFFI_SHARED_HEADER_V4 + #error Combining helper code from multiple versions of uniffi is not supported + #endif // ndef UNIFFI_SHARED_HEADER_V4 +#else +#define UNIFFI_SHARED_H +#define UNIFFI_SHARED_HEADER_V4 +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ + +typedef struct RustBuffer +{ + int32_t capacity; + int32_t len; + uint8_t *_Nullable data; +} RustBuffer; + +typedef int32_t (*ForeignCallback)(uint64_t, int32_t, const uint8_t *_Nonnull, int32_t, RustBuffer *_Nonnull); + +typedef struct ForeignBytes +{ + int32_t len; + const uint8_t *_Nullable data; +} ForeignBytes; + +// Error definitions +typedef struct RustCallStatus { + int8_t code; + RustBuffer errorBuf; +} RustCallStatus; + +// ⚠️ Attention: If you change this #else block (ending in `#endif // def UNIFFI_SHARED_H`) you *must* ⚠️ +// ⚠️ increment the version suffix in all instances of UNIFFI_SHARED_HEADER_V4 in this file. ⚠️ +#endif // def UNIFFI_SHARED_H + +// Continuation callback for UniFFI Futures +typedef void (*UniFfiRustFutureContinuation)(void * _Nonnull, int8_t); + +// Scaffolding functions +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_loginflow(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_loginflow(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_loginflow_is_awaiting_2fa(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_loginflow_is_logged_in(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_login(void*_Nonnull ptr, RustBuffer email, RustBuffer password +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_submit_totp(void*_Nonnull ptr, RustBuffer code +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_loginflow_to_user_context(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailcontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailcontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_constructor_mailcontext_new(RustBuffer session_dir, RustBuffer user_dir, RustBuffer log_dir, int8_t log_debug, uint64_t key_chain, RustBuffer network_callback, RustCallStatus *_Nonnull out_status +); +int8_t uniffi_proton_mail_uniffi_fn_method_mailcontext_is_network_connected(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailcontext_new_login_flow(void*_Nonnull ptr, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailcontext_set_network_connected(void*_Nonnull ptr, int8_t online, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailcontext_stored_sessions(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailcontext_user_context_from_session(void*_Nonnull ptr, void*_Nonnull session, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailusercontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailusercontext(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_initialize(void*_Nonnull ptr, uint64_t cb +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_logout(void*_Nonnull ptr +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailusercontext_mail_settings(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void* _Nonnull uniffi_proton_mail_uniffi_fn_method_mailusercontext_poll_events(void*_Nonnull ptr +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailbox(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailbox(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_constructor_mailbox_new(void*_Nonnull ctx, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_active_label(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_conversations(void*_Nonnull ptr, int64_t count, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailbox_labels_by_type(void*_Nonnull ptr, RustBuffer label_type, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_conversation_observed_query(void*_Nonnull ptr, int64_t limit, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_folder_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_label_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_method_mailbox_new_system_labels_observed_query(void*_Nonnull ptr, uint64_t cb, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailbox_switch_label(void*_Nonnull ptr, uint64_t label_id, int64_t message_count, RustBuffer cb, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailboxconversationlivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailboxconversationlivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_disconnect(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailboxconversationlivequery_value(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_mailboxlabelslivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_mailboxlabelslivequery(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_disconnect(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_mailboxlabelslivequery_value(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void*_Nonnull uniffi_proton_mail_uniffi_fn_clone_storedsession(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_free_storedsession(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_email(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_name(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_session_id(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +RustBuffer uniffi_proton_mail_uniffi_fn_method_storedsession_user_id(void*_Nonnull ptr, RustCallStatus *_Nonnull out_status +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailusercontextinitializationcallback(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailboxbackgroundresult(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_mailboxlivequeryupdatedcallback(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_networkstatuschanged(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_oskeychain(ForeignCallback _Nonnull handle +); +void uniffi_proton_mail_uniffi_fn_init_callback_sessioncallback(ForeignCallback _Nonnull handle +); +RustBuffer uniffi_proton_mail_uniffi_fn_func_locate_blockquote(RustBuffer input, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_alloc(int32_t size, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_from_bytes(ForeignBytes bytes, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rustbuffer_free(RustBuffer buf, RustCallStatus *_Nonnull out_status +); +RustBuffer ffi_proton_mail_uniffi_rustbuffer_reserve(RustBuffer buf, int32_t additional, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u8(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u8(void* _Nonnull handle +); +uint8_t ffi_proton_mail_uniffi_rust_future_complete_u8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i8(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i8(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i8(void* _Nonnull handle +); +int8_t ffi_proton_mail_uniffi_rust_future_complete_i8(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u16(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u16(void* _Nonnull handle +); +uint16_t ffi_proton_mail_uniffi_rust_future_complete_u16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i16(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i16(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i16(void* _Nonnull handle +); +int16_t ffi_proton_mail_uniffi_rust_future_complete_i16(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u32(void* _Nonnull handle +); +uint32_t ffi_proton_mail_uniffi_rust_future_complete_u32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i32(void* _Nonnull handle +); +int32_t ffi_proton_mail_uniffi_rust_future_complete_i32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_u64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_u64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_u64(void* _Nonnull handle +); +uint64_t ffi_proton_mail_uniffi_rust_future_complete_u64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_i64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_i64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_i64(void* _Nonnull handle +); +int64_t ffi_proton_mail_uniffi_rust_future_complete_i64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_f32(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_f32(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_f32(void* _Nonnull handle +); +float ffi_proton_mail_uniffi_rust_future_complete_f32(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_f64(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_f64(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_f64(void* _Nonnull handle +); +double ffi_proton_mail_uniffi_rust_future_complete_f64(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_pointer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_pointer(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_pointer(void* _Nonnull handle +); +void*_Nonnull ffi_proton_mail_uniffi_rust_future_complete_pointer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_rust_buffer(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_rust_buffer(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_rust_buffer(void* _Nonnull handle +); +RustBuffer ffi_proton_mail_uniffi_rust_future_complete_rust_buffer(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +void ffi_proton_mail_uniffi_rust_future_poll_void(void* _Nonnull handle, UniFfiRustFutureContinuation _Nonnull callback, void* _Nonnull callback_data +); +void ffi_proton_mail_uniffi_rust_future_cancel_void(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_free_void(void* _Nonnull handle +); +void ffi_proton_mail_uniffi_rust_future_complete_void(void* _Nonnull handle, RustCallStatus *_Nonnull out_status +); +uint16_t uniffi_proton_mail_uniffi_checksum_func_locate_blockquote(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_is_awaiting_2fa(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_is_logged_in(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_login(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_submit_totp(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_loginflow_to_user_context(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_is_network_connected(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_new_login_flow(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_set_network_connected(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_stored_sessions(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailcontext_user_context_from_session(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_initialize(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_logout(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_mail_settings(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontext_poll_events(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_active_label(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_conversations(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_labels_by_type(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_conversation_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_folder_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_label_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_new_system_labels_observed_query(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailbox_switch_label(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_disconnect(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxconversationlivequery_value(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_disconnect(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlabelslivequery_value(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_email(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_name(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_session_id(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_storedsession_user_id(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_constructor_mailcontext_new(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_constructor_mailbox_new(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailusercontextinitializationcallback_on_stage(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxbackgroundresult_on_background_result(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_mailboxlivequeryupdatedcallback_on_updated(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_networkstatuschanged_on_network_status_changed(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_store(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_delete(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_oskeychain_get(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_refresh(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_session_deleted(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_refresh_failed(void + +); +uint16_t uniffi_proton_mail_uniffi_checksum_method_sessioncallback_on_error(void + +); +uint32_t ffi_proton_mail_uniffi_uniffi_contract_version(void + +); + diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Modules/module.modulemap b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Modules/module.modulemap new file mode 100644 index 0000000000..558be47bd5 --- /dev/null +++ b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/Modules/module.modulemap @@ -0,0 +1,10 @@ +framework module proton_mail_uniffi_ffi { + header "proton_api_coreFFI.h" + header "proton_api_mailFFI.h" + header "proton_core_commonFFI.h" + header "proton_core_dbFFI.h" + header "proton_mail_commonFFI.h" + header "proton_mail_dbFFI.h" + header "proton_mail_uniffiFFI.h" + export * +} diff --git a/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi new file mode 100644 index 0000000000..cb79b1a6a5 Binary files /dev/null and b/localPackages/proton_mail_uniffi/Sources/proton_mail_uniffi_ffi.xcframework/ios-arm64_x86_64-simulator/proton_mail_uniffi_ffi.framework/proton_mail_uniffi_ffi differ diff --git a/project.yml b/project.yml index 26a77e5b31..9ba5e66f5b 100644 --- a/project.yml +++ b/project.yml @@ -18,6 +18,8 @@ packages: minorVersion: "1.30.0" DesignSystem: path: localPackages/DesignSystem + proton_mail_uniffi: + path: localPackages/proton_mail_uniffi targets: ProtonMail: @@ -66,6 +68,7 @@ targets: - UIInterfaceOrientationLandscapeRight dependencies: - package: DesignSystem + - package: proton_mail_uniffi ProtonMailTest: type: bundle.unit-test