Add server editing and deletion
This commit is contained in:
@@ -671,10 +671,14 @@ public protocol GotchaCoreProtocol: AnyObject, Sendable {
|
||||
|
||||
func addServer(name: String, url: String, token: String, provider: ServerProvider) async throws -> UInt32
|
||||
|
||||
func deleteServer(index: UInt32) async throws
|
||||
|
||||
func home(page: UInt32, filter: HomeActivityFilter) async throws -> HomePage
|
||||
|
||||
func selectServer(index: UInt32) throws
|
||||
|
||||
func serverEditor(index: UInt32) throws -> ServerEditor
|
||||
|
||||
func servers() -> [ServerRow]
|
||||
|
||||
func setAppearance(index: UInt32) throws
|
||||
@@ -687,6 +691,8 @@ public protocol GotchaCoreProtocol: AnyObject, Sendable {
|
||||
|
||||
func startupError() -> String?
|
||||
|
||||
func updateServer(index: UInt32, name: String, url: String, token: String, provider: ServerProvider) async throws
|
||||
|
||||
}
|
||||
open class GotchaCore: GotchaCoreProtocol, @unchecked Sendable {
|
||||
fileprivate let handle: UInt64
|
||||
@@ -1240,6 +1246,22 @@ open func addServer(name: String, url: String, token: String, provider: ServerPr
|
||||
)
|
||||
}
|
||||
|
||||
open func deleteServer(index: UInt32)async throws {
|
||||
return
|
||||
try await uniffiRustCallAsync(
|
||||
rustFutureFunc: {
|
||||
uniffi_gotcha_core_fn_method_gotchacore_delete_server(
|
||||
self.uniffiCloneHandle(),FfiConverterUInt32.lower(index)
|
||||
)
|
||||
},
|
||||
pollFunc: ffi_gotcha_core_rust_future_poll_void,
|
||||
completeFunc: ffi_gotcha_core_rust_future_complete_void,
|
||||
freeFunc: ffi_gotcha_core_rust_future_free_void,
|
||||
liftFunc: { $0 },
|
||||
errorHandler: FfiConverterTypeGotchaError_lift
|
||||
)
|
||||
}
|
||||
|
||||
open func home(page: UInt32, filter: HomeActivityFilter)async throws -> HomePage {
|
||||
return
|
||||
try await uniffiRustCallAsync(
|
||||
@@ -1265,6 +1287,16 @@ open func selectServer(index: UInt32)throws {try rustCallWithError(FfiConverte
|
||||
}
|
||||
}
|
||||
|
||||
open func serverEditor(index: UInt32)throws -> ServerEditor {
|
||||
return try FfiConverterTypeServerEditor_lift(try rustCallWithError(FfiConverterTypeGotchaError_lift) {
|
||||
uniffiCallStatus in
|
||||
uniffi_gotcha_core_fn_method_gotchacore_server_editor(
|
||||
self.uniffiCloneHandle(),
|
||||
FfiConverterUInt32.lower(index),uniffiCallStatus
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
open func servers() -> [ServerRow] {
|
||||
return try! FfiConverterSequenceTypeServerRow.lift(try! rustCall() {
|
||||
uniffiCallStatus in
|
||||
@@ -1319,6 +1351,22 @@ open func startupError() -> String? {
|
||||
})
|
||||
}
|
||||
|
||||
open func updateServer(index: UInt32, name: String, url: String, token: String, provider: ServerProvider)async throws {
|
||||
return
|
||||
try await uniffiRustCallAsync(
|
||||
rustFutureFunc: {
|
||||
uniffi_gotcha_core_fn_method_gotchacore_update_server(
|
||||
self.uniffiCloneHandle(),FfiConverterUInt32.lower(index),FfiConverterString.lower(name),FfiConverterString.lower(url),FfiConverterString.lower(token),FfiConverterTypeServerProvider_lower(provider)
|
||||
)
|
||||
},
|
||||
pollFunc: ffi_gotcha_core_rust_future_poll_void,
|
||||
completeFunc: ffi_gotcha_core_rust_future_complete_void,
|
||||
freeFunc: ffi_gotcha_core_rust_future_free_void,
|
||||
liftFunc: { $0 },
|
||||
errorHandler: FfiConverterTypeGotchaError_lift
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -3415,6 +3463,58 @@ public func FfiConverterTypeRepositoryRow_lower(_ value: RepositoryRow) -> RustB
|
||||
}
|
||||
|
||||
|
||||
public struct ServerEditor: Equatable, Hashable {
|
||||
public var name: String
|
||||
public var url: String
|
||||
public var provider: ServerProvider
|
||||
|
||||
// Default memberwise initializers are never public by default, so we
|
||||
// declare one manually.
|
||||
public init(name: String, url: String, provider: ServerProvider) {
|
||||
self.name = name
|
||||
self.url = url
|
||||
self.provider = provider
|
||||
}
|
||||
}
|
||||
|
||||
#if compiler(>=6)
|
||||
extension ServerEditor: Sendable {}
|
||||
#endif
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public struct FfiConverterTypeServerEditor: FfiConverterRustBuffer {
|
||||
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ServerEditor {
|
||||
return
|
||||
try ServerEditor(
|
||||
name: FfiConverterString.read(from: &buf),
|
||||
url: FfiConverterString.read(from: &buf),
|
||||
provider: FfiConverterTypeServerProvider.read(from: &buf)
|
||||
)
|
||||
}
|
||||
|
||||
public static func write(_ value: ServerEditor, into buf: inout [UInt8]) {
|
||||
FfiConverterString.write(value.name, into: &buf)
|
||||
FfiConverterString.write(value.url, into: &buf)
|
||||
FfiConverterTypeServerProvider.write(value.provider, into: &buf)
|
||||
}
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeServerEditor_lift(_ buf: RustBuffer) throws -> ServerEditor {
|
||||
return try FfiConverterTypeServerEditor.lift(buf)
|
||||
}
|
||||
|
||||
#if swift(>=5.8)
|
||||
@_documentation(visibility: private)
|
||||
#endif
|
||||
public func FfiConverterTypeServerEditor_lower(_ value: ServerEditor) -> RustBuffer {
|
||||
return FfiConverterTypeServerEditor.lower(value)
|
||||
}
|
||||
|
||||
public struct ServerRow: Equatable, Hashable {
|
||||
public var name: String
|
||||
public var url: String
|
||||
@@ -5012,12 +5112,18 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_add_server() != 51168) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_delete_server() != 5208) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_home() != 37602) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_select_server() != 10204) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_server_editor() != 36193) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_servers() != 16732) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
@@ -5036,6 +5142,9 @@ private let initializationResult: InitializationResult = {
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_startup_error() != 58843) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_method_gotchacore_update_server() != 31001) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
if (uniffi_gotcha_core_checksum_constructor_gotchacore_new() != 35044) {
|
||||
return InitializationResult.apiChecksumMismatch
|
||||
}
|
||||
@@ -5056,4 +5165,4 @@ public func uniffiEnsureGotchaCoreInitialized() {
|
||||
}
|
||||
}
|
||||
|
||||
// swiftlint:enable all
|
||||
// swiftlint:enable all
|
||||
|
||||
Reference in New Issue
Block a user