From 4cb8f8f3326b5ad659afd428a3e312aa397fb9c5 Mon Sep 17 00:00:00 2001 From: sarveshsharma Date: Wed, 11 Dec 2024 19:47:23 +0530 Subject: [PATCH] build: Adds grpc integration --- iosApp/iosApp.xcodeproj/project.pbxproj | 93 ++- .../xcshareddata/swiftpm/Package.resolved | 101 ++- iosApp/iosApp/grpc/ml_feed.grpc.swift | 693 ++++++++++++++++++ iosApp/iosApp/grpc/ml_feed.pb.swift | 346 +++++++++ iosApp/iosApp/grpc/ml_feed.proto | 37 + 5 files changed, 1268 insertions(+), 2 deletions(-) create mode 100644 iosApp/iosApp/grpc/ml_feed.grpc.swift create mode 100644 iosApp/iosApp/grpc/ml_feed.pb.swift create mode 100644 iosApp/iosApp/grpc/ml_feed.proto diff --git a/iosApp/iosApp.xcodeproj/project.pbxproj b/iosApp/iosApp.xcodeproj/project.pbxproj index 653e122..c0d5e7e 100644 --- a/iosApp/iosApp.xcodeproj/project.pbxproj +++ b/iosApp/iosApp.xcodeproj/project.pbxproj @@ -16,6 +16,14 @@ AC09A9FA2CDB7A5D009A39A4 /* SwiftBindings+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC09A9F92CDB7A5D009A39A4 /* SwiftBindings+Extensions.swift */; }; AC09AA742CDD210D009A39A4 /* Data+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC09AA732CDD2107009A39A4 /* Data+Extensions.swift */; }; AC0E49C42CEBA6F0002DC158 /* secp256k1 in Frameworks */ = {isa = PBXBuildFile; productRef = AC0E49C32CEBA6F0002DC158 /* secp256k1 */; }; + AC6BECAA2D09D52B002E2021 /* CGRPCZlib in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECA92D09D52B002E2021 /* CGRPCZlib */; }; + AC6BECAC2D09D52B002E2021 /* GRPC in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECAB2D09D52B002E2021 /* GRPC */; }; + AC6BECAE2D09D52B002E2021 /* GRPCReflectionService in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECAD2D09D52B002E2021 /* GRPCReflectionService */; }; + AC6BECB02D09D52B002E2021 /* protoc-gen-grpc-swift in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECAF2D09D52B002E2021 /* protoc-gen-grpc-swift */; }; + AC6BECB22D09D541002E2021 /* CGRPCZlib in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECB12D09D541002E2021 /* CGRPCZlib */; }; + AC6BECB42D09D541002E2021 /* GRPC in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECB32D09D541002E2021 /* GRPC */; }; + AC6BECB62D09D541002E2021 /* GRPCReflectionService in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECB52D09D541002E2021 /* GRPCReflectionService */; }; + AC6BECB82D09D55B002E2021 /* protoc-gen-grpc-swift in Frameworks */ = {isa = PBXBuildFile; productRef = AC6BECB72D09D55B002E2021 /* protoc-gen-grpc-swift */; }; AC6CBA802CE46CA6002454F8 /* libyral_mobile_swift_binding.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AC09A9F72CDB78B9009A39A4 /* libyral_mobile_swift_binding.a */; }; ACB815372CF9D4FF00104B7B /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = ACB815342CF9CE0800104B7B /* GoogleService-Info.plist */; }; ACB815482CFA146800104B7B /* FirebaseCore in Frameworks */ = {isa = PBXBuildFile; productRef = ACB815472CFA146800104B7B /* FirebaseCore */; }; @@ -40,6 +48,12 @@ ACD941D12CFF5B720038FCB6 /* secp256k1 in Frameworks */ = {isa = PBXBuildFile; productRef = ACD941D02CFF5B720038FCB6 /* secp256k1 */; }; ACD941D32CFF5B8B0038FCB6 /* secp256k1 in Frameworks */ = {isa = PBXBuildFile; productRef = ACD941D22CFF5B8B0038FCB6 /* secp256k1 */; }; ACD941D92CFF63D90038FCB6 /* libyral_mobile_swift_binding.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AC09A9F72CDB78B9009A39A4 /* libyral_mobile_swift_binding.a */; }; + ACF4EFC62D09CC0400086ADF /* ml_feed.proto in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC42D09CC0400086ADF /* ml_feed.proto */; }; + ACF4EFC72D09CC0400086ADF /* ml_feed.proto in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC42D09CC0400086ADF /* ml_feed.proto */; }; + ACF4EFCA2D09D39400086ADF /* ml_feed.grpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC82D09D39400086ADF /* ml_feed.grpc.swift */; }; + ACF4EFCB2D09D39400086ADF /* ml_feed.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC92D09D39400086ADF /* ml_feed.pb.swift */; }; + ACF4EFCC2D09D39400086ADF /* ml_feed.grpc.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC82D09D39400086ADF /* ml_feed.grpc.swift */; }; + ACF4EFCD2D09D39400086ADF /* ml_feed.pb.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF4EFC92D09D39400086ADF /* ml_feed.pb.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -62,6 +76,9 @@ ACD941B92CFF575C0038FCB6 /* Info-Staging.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-Staging.plist"; path = "/Users/sarveshsharma/Desktop/yral-mobile/iosApp/Staging/Info-Staging.plist"; sourceTree = ""; }; ACD941BA2CFF579A0038FCB6 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; ACD941BE2CFF58B10038FCB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ACF4EFC42D09CC0400086ADF /* ml_feed.proto */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.protobuf; path = ml_feed.proto; sourceTree = ""; }; + ACF4EFC82D09D39400086ADF /* ml_feed.grpc.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ml_feed.grpc.swift; sourceTree = ""; }; + ACF4EFC92D09D39400086ADF /* ml_feed.pb.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ml_feed.pb.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -70,12 +87,16 @@ buildActionMask = 2147483647; files = ( AC6CBA802CE46CA6002454F8 /* libyral_mobile_swift_binding.a in Frameworks */, + AC6BECAC2D09D52B002E2021 /* GRPC in Frameworks */, ACD941D12CFF5B720038FCB6 /* secp256k1 in Frameworks */, AC0E49C42CEBA6F0002DC158 /* secp256k1 in Frameworks */, ACD941C22CFF5B3D0038FCB6 /* FirebaseAnalytics in Frameworks */, ACD941802CFF55BB0038FCB6 /* FirebaseAnalyticsWithoutAdIdSupport in Frameworks */, ACD941C42CFF5B3D0038FCB6 /* FirebaseCore in Frameworks */, ACD941C62CFF5B3D0038FCB6 /* FirebaseCrashlytics in Frameworks */, + AC6BECAA2D09D52B002E2021 /* CGRPCZlib in Frameworks */, + AC6BECB02D09D52B002E2021 /* protoc-gen-grpc-swift in Frameworks */, + AC6BECAE2D09D52B002E2021 /* GRPCReflectionService in Frameworks */, ACB815482CFA146800104B7B /* FirebaseCore in Frameworks */, ACD941822CFF55BB0038FCB6 /* FirebaseCrashlytics in Frameworks */, ); @@ -85,8 +106,12 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + AC6BECB42D09D541002E2021 /* GRPC in Frameworks */, ACD941C82CFF5B5B0038FCB6 /* FirebaseAnalytics in Frameworks */, ACD941D92CFF63D90038FCB6 /* libyral_mobile_swift_binding.a in Frameworks */, + AC6BECB62D09D541002E2021 /* GRPCReflectionService in Frameworks */, + AC6BECB82D09D55B002E2021 /* protoc-gen-grpc-swift in Frameworks */, + AC6BECB22D09D541002E2021 /* CGRPCZlib in Frameworks */, ACD941D32CFF5B8B0038FCB6 /* secp256k1 in Frameworks */, ACD941CA2CFF5B5B0038FCB6 /* FirebaseAnalyticsOnDeviceConversion in Frameworks */, ACD941CE2CFF5B5B0038FCB6 /* FirebaseCrashlytics in Frameworks */, @@ -130,6 +155,7 @@ 7555FF7D242A565900829871 /* iosApp */ = { isa = PBXGroup; children = ( + ACF4EFC52D09CC0400086ADF /* grpc */, 058557BA273AAA24004C7B11 /* Assets.xcassets */, 7555FF82242A565900829871 /* ContentView.swift */, AC09AA1E2CDBB69B009A39A4 /* Extensions */, @@ -194,6 +220,16 @@ path = Staging; sourceTree = ""; }; + ACF4EFC52D09CC0400086ADF /* grpc */ = { + isa = PBXGroup; + children = ( + ACF4EFC82D09D39400086ADF /* ml_feed.grpc.swift */, + ACF4EFC92D09D39400086ADF /* ml_feed.pb.swift */, + ACF4EFC42D09CC0400086ADF /* ml_feed.proto */, + ); + path = grpc; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -264,6 +300,7 @@ packageReferences = ( ACD941C02CFF5B3D0038FCB6 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */, ACD941CF2CFF5B720038FCB6 /* XCRemoteSwiftPackageReference "swift-secp256k1" */, + AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */, ); productRefGroup = 7555FF7C242A565900829871 /* Products */; projectDirPath = ""; @@ -374,7 +411,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n./build-rust.sh\n"; + shellScript = "# Type a script or drag a script file from your workspace to insert its path.\n#./build-rust.sh\n"; }; ACD941852CFF575C0038FCB6 /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -426,10 +463,13 @@ files = ( 2152FB042600AC8F00CF470E /* IosApp.swift in Sources */, AC09A9B22CDB775C009A39A4 /* yral-mobile-swift-binding.swift in Sources */, + ACF4EFCA2D09D39400086ADF /* ml_feed.grpc.swift in Sources */, + ACF4EFCB2D09D39400086ADF /* ml_feed.pb.swift in Sources */, AC09A9B32CDB775C009A39A4 /* SwiftBridgeCore.swift in Sources */, AC09AA742CDD210D009A39A4 /* Data+Extensions.swift in Sources */, AC09A9FA2CDB7A5D009A39A4 /* SwiftBindings+Extensions.swift in Sources */, 7555FF83242A565900829871 /* ContentView.swift in Sources */, + ACF4EFC72D09CC0400086ADF /* ml_feed.proto in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -439,10 +479,13 @@ files = ( ACD941872CFF575C0038FCB6 /* IosApp.swift in Sources */, ACD941882CFF575C0038FCB6 /* yral-mobile-swift-binding.swift in Sources */, + ACF4EFCC2D09D39400086ADF /* ml_feed.grpc.swift in Sources */, + ACF4EFCD2D09D39400086ADF /* ml_feed.pb.swift in Sources */, ACD941892CFF575C0038FCB6 /* SwiftBridgeCore.swift in Sources */, ACD9418A2CFF575C0038FCB6 /* Data+Extensions.swift in Sources */, ACD9418B2CFF575C0038FCB6 /* SwiftBindings+Extensions.swift in Sources */, ACD9418C2CFF575C0038FCB6 /* ContentView.swift in Sources */, + ACF4EFC62D09CC0400086ADF /* ml_feed.proto in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -728,6 +771,14 @@ minimumVersion = 0.18.0; }; }; + AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/grpc/grpc-swift.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.24.2; + }; + }; ACB815382CFA146800104B7B /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/firebase/firebase-ios-sdk.git"; @@ -768,6 +819,46 @@ package = AC0E49C22CEBA6F0002DC158 /* XCRemoteSwiftPackageReference "swift-secp256k1" */; productName = secp256k1; }; + AC6BECA92D09D52B002E2021 /* CGRPCZlib */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = CGRPCZlib; + }; + AC6BECAB2D09D52B002E2021 /* GRPC */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = GRPC; + }; + AC6BECAD2D09D52B002E2021 /* GRPCReflectionService */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = GRPCReflectionService; + }; + AC6BECAF2D09D52B002E2021 /* protoc-gen-grpc-swift */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = "protoc-gen-grpc-swift"; + }; + AC6BECB12D09D541002E2021 /* CGRPCZlib */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = CGRPCZlib; + }; + AC6BECB32D09D541002E2021 /* GRPC */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = GRPC; + }; + AC6BECB52D09D541002E2021 /* GRPCReflectionService */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = GRPCReflectionService; + }; + AC6BECB72D09D55B002E2021 /* protoc-gen-grpc-swift */ = { + isa = XCSwiftPackageProductDependency; + package = AC6BECA82D09D52B002E2021 /* XCRemoteSwiftPackageReference "grpc-swift" */; + productName = "protoc-gen-grpc-swift"; + }; ACB815472CFA146800104B7B /* FirebaseCore */ = { isa = XCSwiftPackageProductDependency; package = ACB815382CFA146800104B7B /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */; diff --git a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index fe40e83..d7d8d0d 100644 --- a/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/iosApp/iosApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e83acd66c47b7b14963301da43d3bb7254e3f7caa10d651f8f0f22850a65d063", + "originHash" : "a0965f4e9b93edf9c178ef89aced2538f8fa62f7e25153cc3136373d5a8ed2b1", "pins" : [ { "identity" : "abseil-cpp-binary", @@ -64,6 +64,15 @@ "version" : "1.65.1" } }, + { + "identity" : "grpc-swift", + "kind" : "remoteSourceControl", + "location" : "https://github.com/grpc/grpc-swift.git", + "state" : { + "revision" : "8c5e99d0255c373e0330730d191a3423c57373fb", + "version" : "1.24.2" + } + }, { "identity" : "gtm-session-fetcher", "kind" : "remoteSourceControl", @@ -109,6 +118,87 @@ "version" : "2.4.0" } }, + { + "identity" : "swift-atomics", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-atomics.git", + "state" : { + "revision" : "cd142fd2f64be2100422d658e7411e39489da985", + "version" : "1.2.0" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections.git", + "state" : { + "revision" : "671108c96644956dddcd89dd59c203dcdb36cec7", + "version" : "1.1.4" + } + }, + { + "identity" : "swift-http-types", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-http-types", + "state" : { + "revision" : "ef18d829e8b92d731ad27bb81583edd2094d1ce3", + "version" : "1.3.1" + } + }, + { + "identity" : "swift-log", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-log.git", + "state" : { + "revision" : "96a2f8a0fa41e9e09af4585e2724c4e825410b91", + "version" : "1.6.2" + } + }, + { + "identity" : "swift-nio", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio.git", + "state" : { + "revision" : "dca6594f65308c761a9c409e09fbf35f48d50d34", + "version" : "2.77.0" + } + }, + { + "identity" : "swift-nio-extras", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-extras.git", + "state" : { + "revision" : "2e9746cfc57554f70b650b021b6ae4738abef3e6", + "version" : "1.24.1" + } + }, + { + "identity" : "swift-nio-http2", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-http2.git", + "state" : { + "revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca", + "version" : "1.34.1" + } + }, + { + "identity" : "swift-nio-ssl", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-ssl.git", + "state" : { + "revision" : "c7e95421334b1068490b5d41314a50e70bab23d1", + "version" : "2.29.0" + } + }, + { + "identity" : "swift-nio-transport-services", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-nio-transport-services.git", + "state" : { + "revision" : "bbd5e63cf949b7db0c9edaf7a21e141c52afe214", + "version" : "1.23.0" + } + }, { "identity" : "swift-protobuf", "kind" : "remoteSourceControl", @@ -126,6 +216,15 @@ "revision" : "57ce9af6db14e0114af631ace25231a9d0ccccbd", "version" : "0.18.0" } + }, + { + "identity" : "swift-system", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-system.git", + "state" : { + "revision" : "c8a44d836fe7913603e246acab7c528c2e780168", + "version" : "1.4.0" + } } ], "version" : 3 diff --git a/iosApp/iosApp/grpc/ml_feed.grpc.swift b/iosApp/iosApp/grpc/ml_feed.grpc.swift new file mode 100644 index 0000000..668835a --- /dev/null +++ b/iosApp/iosApp/grpc/ml_feed.grpc.swift @@ -0,0 +1,693 @@ +// +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the protocol buffer compiler. +// Source: ml_feed.proto +// +import GRPC +import NIO +import NIOConcurrencyHelpers +import SwiftProtobuf + + +/// Usage: instantiate `MlFeed_MLFeedClient`, then call methods of this protocol to make API calls. +internal protocol MlFeed_MLFeedClientProtocol: GRPCClient { + var serviceName: String { get } + var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? { get } + + func get_feed( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func get_feed_v1( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func get_feed_clean( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func get_feed_nsfw( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> UnaryCall + + func get_feed_coldstart( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> UnaryCall +} + +extension MlFeed_MLFeedClientProtocol { + internal var serviceName: String { + return "ml_feed.MLFeed" + } + + /// Unary call to get_feed + /// + /// - Parameters: + /// - request: Request to send to get_feed. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func get_feed( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feedInterceptors() ?? [] + ) + } + + /// Unary call to get_feed_v1 + /// + /// - Parameters: + /// - request: Request to send to get_feed_v1. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func get_feed_v1( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_v1.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_v1Interceptors() ?? [] + ) + } + + /// Unary call to get_feed_clean + /// + /// - Parameters: + /// - request: Request to send to get_feed_clean. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func get_feed_clean( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_clean.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_cleanInterceptors() ?? [] + ) + } + + /// Unary call to get_feed_nsfw + /// + /// - Parameters: + /// - request: Request to send to get_feed_nsfw. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func get_feed_nsfw( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_nsfw.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_nsfwInterceptors() ?? [] + ) + } + + /// Unary call to get_feed_coldstart + /// + /// - Parameters: + /// - request: Request to send to get_feed_coldstart. + /// - callOptions: Call options. + /// - Returns: A `UnaryCall` with futures for the metadata, status and response. + internal func get_feed_coldstart( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> UnaryCall { + return self.makeUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_coldstart.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_coldstartInterceptors() ?? [] + ) + } +} + +@available(*, deprecated) +extension MlFeed_MLFeedClient: @unchecked Sendable {} + +@available(*, deprecated, renamed: "MlFeed_MLFeedNIOClient") +internal final class MlFeed_MLFeedClient: MlFeed_MLFeedClientProtocol { + private let lock = Lock() + private var _defaultCallOptions: CallOptions + private var _interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? + internal let channel: GRPCChannel + internal var defaultCallOptions: CallOptions { + get { self.lock.withLock { return self._defaultCallOptions } } + set { self.lock.withLockVoid { self._defaultCallOptions = newValue } } + } + internal var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? { + get { self.lock.withLock { return self._interceptors } } + set { self.lock.withLockVoid { self._interceptors = newValue } } + } + + /// Creates a client for the ml_feed.MLFeed service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self._defaultCallOptions = defaultCallOptions + self._interceptors = interceptors + } +} + +internal struct MlFeed_MLFeedNIOClient: MlFeed_MLFeedClientProtocol { + internal var channel: GRPCChannel + internal var defaultCallOptions: CallOptions + internal var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? + + /// Creates a client for the ml_feed.MLFeed service. + /// + /// - Parameters: + /// - channel: `GRPCChannel` to the service host. + /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them. + /// - interceptors: A factory providing interceptors for each RPC. + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal protocol MlFeed_MLFeedAsyncClientProtocol: GRPCClient { + static var serviceDescriptor: GRPCServiceDescriptor { get } + var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? { get } + + func makeGetFeedCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall + + func makeGetFeedV1Call( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall + + func makeGetFeedCleanCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall + + func makeGetFeedNsfwCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall + + func makeGetFeedColdstartCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? + ) -> GRPCAsyncUnaryCall +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension MlFeed_MLFeedAsyncClientProtocol { + internal static var serviceDescriptor: GRPCServiceDescriptor { + return MlFeed_MLFeedClientMetadata.serviceDescriptor + } + + internal var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? { + return nil + } + + internal func makeGetFeedCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feedInterceptors() ?? [] + ) + } + + internal func makeGetFeedV1Call( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_v1.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_v1Interceptors() ?? [] + ) + } + + internal func makeGetFeedCleanCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_clean.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_cleanInterceptors() ?? [] + ) + } + + internal func makeGetFeedNsfwCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_nsfw.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_nsfwInterceptors() ?? [] + ) + } + + internal func makeGetFeedColdstartCall( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) -> GRPCAsyncUnaryCall { + return self.makeAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_coldstart.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_coldstartInterceptors() ?? [] + ) + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension MlFeed_MLFeedAsyncClientProtocol { + internal func get_feed( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) async throws -> MlFeed_FeedResponse { + return try await self.performAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feedInterceptors() ?? [] + ) + } + + internal func get_feed_v1( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) async throws -> MlFeed_FeedResponseV1 { + return try await self.performAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_v1.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_v1Interceptors() ?? [] + ) + } + + internal func get_feed_clean( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) async throws -> MlFeed_FeedResponse { + return try await self.performAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_clean.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_cleanInterceptors() ?? [] + ) + } + + internal func get_feed_nsfw( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) async throws -> MlFeed_FeedResponse { + return try await self.performAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_nsfw.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_nsfwInterceptors() ?? [] + ) + } + + internal func get_feed_coldstart( + _ request: MlFeed_FeedRequest, + callOptions: CallOptions? = nil + ) async throws -> MlFeed_FeedResponse { + return try await self.performAsyncUnaryCall( + path: MlFeed_MLFeedClientMetadata.Methods.get_feed_coldstart.path, + request: request, + callOptions: callOptions ?? self.defaultCallOptions, + interceptors: self.interceptors?.makeget_feed_coldstartInterceptors() ?? [] + ) + } +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal struct MlFeed_MLFeedAsyncClient: MlFeed_MLFeedAsyncClientProtocol { + internal var channel: GRPCChannel + internal var defaultCallOptions: CallOptions + internal var interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? + + internal init( + channel: GRPCChannel, + defaultCallOptions: CallOptions = CallOptions(), + interceptors: MlFeed_MLFeedClientInterceptorFactoryProtocol? = nil + ) { + self.channel = channel + self.defaultCallOptions = defaultCallOptions + self.interceptors = interceptors + } +} + +internal protocol MlFeed_MLFeedClientInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when invoking 'get_feed'. + func makeget_feedInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'get_feed_v1'. + func makeget_feed_v1Interceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'get_feed_clean'. + func makeget_feed_cleanInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'get_feed_nsfw'. + func makeget_feed_nsfwInterceptors() -> [ClientInterceptor] + + /// - Returns: Interceptors to use when invoking 'get_feed_coldstart'. + func makeget_feed_coldstartInterceptors() -> [ClientInterceptor] +} + +internal enum MlFeed_MLFeedClientMetadata { + internal static let serviceDescriptor = GRPCServiceDescriptor( + name: "MLFeed", + fullName: "ml_feed.MLFeed", + methods: [ + MlFeed_MLFeedClientMetadata.Methods.get_feed, + MlFeed_MLFeedClientMetadata.Methods.get_feed_v1, + MlFeed_MLFeedClientMetadata.Methods.get_feed_clean, + MlFeed_MLFeedClientMetadata.Methods.get_feed_nsfw, + MlFeed_MLFeedClientMetadata.Methods.get_feed_coldstart, + ] + ) + + internal enum Methods { + internal static let get_feed = GRPCMethodDescriptor( + name: "get_feed", + path: "/ml_feed.MLFeed/get_feed", + type: GRPCCallType.unary + ) + + internal static let get_feed_v1 = GRPCMethodDescriptor( + name: "get_feed_v1", + path: "/ml_feed.MLFeed/get_feed_v1", + type: GRPCCallType.unary + ) + + internal static let get_feed_clean = GRPCMethodDescriptor( + name: "get_feed_clean", + path: "/ml_feed.MLFeed/get_feed_clean", + type: GRPCCallType.unary + ) + + internal static let get_feed_nsfw = GRPCMethodDescriptor( + name: "get_feed_nsfw", + path: "/ml_feed.MLFeed/get_feed_nsfw", + type: GRPCCallType.unary + ) + + internal static let get_feed_coldstart = GRPCMethodDescriptor( + name: "get_feed_coldstart", + path: "/ml_feed.MLFeed/get_feed_coldstart", + type: GRPCCallType.unary + ) + } +} + +/// To build a server, implement a class that conforms to this protocol. +internal protocol MlFeed_MLFeedProvider: CallHandlerProvider { + var interceptors: MlFeed_MLFeedServerInterceptorFactoryProtocol? { get } + + func get_feed(request: MlFeed_FeedRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + func get_feed_v1(request: MlFeed_FeedRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + func get_feed_clean(request: MlFeed_FeedRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + func get_feed_nsfw(request: MlFeed_FeedRequest, context: StatusOnlyCallContext) -> EventLoopFuture + + func get_feed_coldstart(request: MlFeed_FeedRequest, context: StatusOnlyCallContext) -> EventLoopFuture +} + +extension MlFeed_MLFeedProvider { + internal var serviceName: Substring { + return MlFeed_MLFeedServerMetadata.serviceDescriptor.fullName[...] + } + + /// Determines, calls and returns the appropriate request handler, depending on the request's method. + /// Returns nil for methods not handled by this service. + internal func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "get_feed": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feedInterceptors() ?? [], + userFunction: self.get_feed(request:context:) + ) + + case "get_feed_v1": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_v1Interceptors() ?? [], + userFunction: self.get_feed_v1(request:context:) + ) + + case "get_feed_clean": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_cleanInterceptors() ?? [], + userFunction: self.get_feed_clean(request:context:) + ) + + case "get_feed_nsfw": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_nsfwInterceptors() ?? [], + userFunction: self.get_feed_nsfw(request:context:) + ) + + case "get_feed_coldstart": + return UnaryServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_coldstartInterceptors() ?? [], + userFunction: self.get_feed_coldstart(request:context:) + ) + + default: + return nil + } + } +} + +/// To implement a server, implement an object which conforms to this protocol. +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +internal protocol MlFeed_MLFeedAsyncProvider: CallHandlerProvider, Sendable { + static var serviceDescriptor: GRPCServiceDescriptor { get } + var interceptors: MlFeed_MLFeedServerInterceptorFactoryProtocol? { get } + + func get_feed( + request: MlFeed_FeedRequest, + context: GRPCAsyncServerCallContext + ) async throws -> MlFeed_FeedResponse + + func get_feed_v1( + request: MlFeed_FeedRequest, + context: GRPCAsyncServerCallContext + ) async throws -> MlFeed_FeedResponseV1 + + func get_feed_clean( + request: MlFeed_FeedRequest, + context: GRPCAsyncServerCallContext + ) async throws -> MlFeed_FeedResponse + + func get_feed_nsfw( + request: MlFeed_FeedRequest, + context: GRPCAsyncServerCallContext + ) async throws -> MlFeed_FeedResponse + + func get_feed_coldstart( + request: MlFeed_FeedRequest, + context: GRPCAsyncServerCallContext + ) async throws -> MlFeed_FeedResponse +} + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +extension MlFeed_MLFeedAsyncProvider { + internal static var serviceDescriptor: GRPCServiceDescriptor { + return MlFeed_MLFeedServerMetadata.serviceDescriptor + } + + internal var serviceName: Substring { + return MlFeed_MLFeedServerMetadata.serviceDescriptor.fullName[...] + } + + internal var interceptors: MlFeed_MLFeedServerInterceptorFactoryProtocol? { + return nil + } + + internal func handle( + method name: Substring, + context: CallHandlerContext + ) -> GRPCServerHandlerProtocol? { + switch name { + case "get_feed": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feedInterceptors() ?? [], + wrapping: { try await self.get_feed(request: $0, context: $1) } + ) + + case "get_feed_v1": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_v1Interceptors() ?? [], + wrapping: { try await self.get_feed_v1(request: $0, context: $1) } + ) + + case "get_feed_clean": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_cleanInterceptors() ?? [], + wrapping: { try await self.get_feed_clean(request: $0, context: $1) } + ) + + case "get_feed_nsfw": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_nsfwInterceptors() ?? [], + wrapping: { try await self.get_feed_nsfw(request: $0, context: $1) } + ) + + case "get_feed_coldstart": + return GRPCAsyncServerHandler( + context: context, + requestDeserializer: ProtobufDeserializer(), + responseSerializer: ProtobufSerializer(), + interceptors: self.interceptors?.makeget_feed_coldstartInterceptors() ?? [], + wrapping: { try await self.get_feed_coldstart(request: $0, context: $1) } + ) + + default: + return nil + } + } +} + +internal protocol MlFeed_MLFeedServerInterceptorFactoryProtocol: Sendable { + + /// - Returns: Interceptors to use when handling 'get_feed'. + /// Defaults to calling `self.makeInterceptors()`. + func makeget_feedInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'get_feed_v1'. + /// Defaults to calling `self.makeInterceptors()`. + func makeget_feed_v1Interceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'get_feed_clean'. + /// Defaults to calling `self.makeInterceptors()`. + func makeget_feed_cleanInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'get_feed_nsfw'. + /// Defaults to calling `self.makeInterceptors()`. + func makeget_feed_nsfwInterceptors() -> [ServerInterceptor] + + /// - Returns: Interceptors to use when handling 'get_feed_coldstart'. + /// Defaults to calling `self.makeInterceptors()`. + func makeget_feed_coldstartInterceptors() -> [ServerInterceptor] +} + +internal enum MlFeed_MLFeedServerMetadata { + internal static let serviceDescriptor = GRPCServiceDescriptor( + name: "MLFeed", + fullName: "ml_feed.MLFeed", + methods: [ + MlFeed_MLFeedServerMetadata.Methods.get_feed, + MlFeed_MLFeedServerMetadata.Methods.get_feed_v1, + MlFeed_MLFeedServerMetadata.Methods.get_feed_clean, + MlFeed_MLFeedServerMetadata.Methods.get_feed_nsfw, + MlFeed_MLFeedServerMetadata.Methods.get_feed_coldstart, + ] + ) + + internal enum Methods { + internal static let get_feed = GRPCMethodDescriptor( + name: "get_feed", + path: "/ml_feed.MLFeed/get_feed", + type: GRPCCallType.unary + ) + + internal static let get_feed_v1 = GRPCMethodDescriptor( + name: "get_feed_v1", + path: "/ml_feed.MLFeed/get_feed_v1", + type: GRPCCallType.unary + ) + + internal static let get_feed_clean = GRPCMethodDescriptor( + name: "get_feed_clean", + path: "/ml_feed.MLFeed/get_feed_clean", + type: GRPCCallType.unary + ) + + internal static let get_feed_nsfw = GRPCMethodDescriptor( + name: "get_feed_nsfw", + path: "/ml_feed.MLFeed/get_feed_nsfw", + type: GRPCCallType.unary + ) + + internal static let get_feed_coldstart = GRPCMethodDescriptor( + name: "get_feed_coldstart", + path: "/ml_feed.MLFeed/get_feed_coldstart", + type: GRPCCallType.unary + ) + } +} +// swiftlint:enable all diff --git a/iosApp/iosApp/grpc/ml_feed.pb.swift b/iosApp/iosApp/grpc/ml_feed.pb.swift new file mode 100644 index 0000000..8c33470 --- /dev/null +++ b/iosApp/iosApp/grpc/ml_feed.pb.swift @@ -0,0 +1,346 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: ml_feed.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import SwiftProtobuf + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +struct MlFeed_PostItem: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var postID: UInt32 = 0 + + var canisterID: String = String() + + var videoID: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct MlFeed_PostItemResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var postID: UInt32 = 0 + + var canisterID: String = String() + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct MlFeed_PostItemResponseV1: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var postID: UInt32 = 0 + + var canisterID: String = String() + + var score: Float = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct MlFeed_FeedRequest: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var canisterID: String = String() + + var filterPosts: [MlFeed_PostItem] = [] + + var numResults: UInt32 = 0 + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct MlFeed_FeedResponse: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var feed: [MlFeed_PostItemResponse] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +struct MlFeed_FeedResponseV1: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + var feed: [MlFeed_PostItemResponseV1] = [] + + var unknownFields = SwiftProtobuf.UnknownStorage() + + init() {} +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "ml_feed" + +extension MlFeed_PostItem: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PostItem" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "post_id"), + 2: .standard(proto: "canister_id"), + 3: .standard(proto: "video_id"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.postID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.canisterID) }() + case 3: try { try decoder.decodeSingularStringField(value: &self.videoID) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.postID != 0 { + try visitor.visitSingularUInt32Field(value: self.postID, fieldNumber: 1) + } + if !self.canisterID.isEmpty { + try visitor.visitSingularStringField(value: self.canisterID, fieldNumber: 2) + } + if !self.videoID.isEmpty { + try visitor.visitSingularStringField(value: self.videoID, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_PostItem, rhs: MlFeed_PostItem) -> Bool { + if lhs.postID != rhs.postID {return false} + if lhs.canisterID != rhs.canisterID {return false} + if lhs.videoID != rhs.videoID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension MlFeed_PostItemResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PostItemResponse" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "post_id"), + 2: .standard(proto: "canister_id"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.postID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.canisterID) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.postID != 0 { + try visitor.visitSingularUInt32Field(value: self.postID, fieldNumber: 1) + } + if !self.canisterID.isEmpty { + try visitor.visitSingularStringField(value: self.canisterID, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_PostItemResponse, rhs: MlFeed_PostItemResponse) -> Bool { + if lhs.postID != rhs.postID {return false} + if lhs.canisterID != rhs.canisterID {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension MlFeed_PostItemResponseV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".PostItemResponseV1" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "post_id"), + 2: .standard(proto: "canister_id"), + 3: .same(proto: "score"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularUInt32Field(value: &self.postID) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.canisterID) }() + case 3: try { try decoder.decodeSingularFloatField(value: &self.score) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if self.postID != 0 { + try visitor.visitSingularUInt32Field(value: self.postID, fieldNumber: 1) + } + if !self.canisterID.isEmpty { + try visitor.visitSingularStringField(value: self.canisterID, fieldNumber: 2) + } + if self.score.bitPattern != 0 { + try visitor.visitSingularFloatField(value: self.score, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_PostItemResponseV1, rhs: MlFeed_PostItemResponseV1) -> Bool { + if lhs.postID != rhs.postID {return false} + if lhs.canisterID != rhs.canisterID {return false} + if lhs.score != rhs.score {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension MlFeed_FeedRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".FeedRequest" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .standard(proto: "canister_id"), + 2: .standard(proto: "filter_posts"), + 3: .standard(proto: "num_results"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.canisterID) }() + case 2: try { try decoder.decodeRepeatedMessageField(value: &self.filterPosts) }() + case 3: try { try decoder.decodeSingularUInt32Field(value: &self.numResults) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.canisterID.isEmpty { + try visitor.visitSingularStringField(value: self.canisterID, fieldNumber: 1) + } + if !self.filterPosts.isEmpty { + try visitor.visitRepeatedMessageField(value: self.filterPosts, fieldNumber: 2) + } + if self.numResults != 0 { + try visitor.visitSingularUInt32Field(value: self.numResults, fieldNumber: 3) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_FeedRequest, rhs: MlFeed_FeedRequest) -> Bool { + if lhs.canisterID != rhs.canisterID {return false} + if lhs.filterPosts != rhs.filterPosts {return false} + if lhs.numResults != rhs.numResults {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension MlFeed_FeedResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".FeedResponse" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "feed"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.feed) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.feed.isEmpty { + try visitor.visitRepeatedMessageField(value: self.feed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_FeedResponse, rhs: MlFeed_FeedResponse) -> Bool { + if lhs.feed != rhs.feed {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension MlFeed_FeedResponseV1: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = _protobuf_package + ".FeedResponseV1" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "feed"), + ] + + mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeRepeatedMessageField(value: &self.feed) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if !self.feed.isEmpty { + try visitor.visitRepeatedMessageField(value: self.feed, fieldNumber: 1) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: MlFeed_FeedResponseV1, rhs: MlFeed_FeedResponseV1) -> Bool { + if lhs.feed != rhs.feed {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} +// swiftlint:enable all diff --git a/iosApp/iosApp/grpc/ml_feed.proto b/iosApp/iosApp/grpc/ml_feed.proto new file mode 100644 index 0000000..b8352b0 --- /dev/null +++ b/iosApp/iosApp/grpc/ml_feed.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; + +package ml_feed; + +message PostItem { + uint32 post_id = 1; + string canister_id = 2; + string video_id = 3; +} + +message PostItemResponse { + uint32 post_id = 1; + string canister_id = 2; +} + +message PostItemResponseV1 { + uint32 post_id = 1; + string canister_id = 2; + float score = 3; +} + +message FeedRequest { + string canister_id = 1; + repeated PostItem filter_posts = 2; + uint32 num_results = 3; +} + +message FeedResponse { repeated PostItemResponse feed = 1; } +message FeedResponseV1 { repeated PostItemResponseV1 feed = 1; } + +service MLFeed { + rpc get_feed(FeedRequest) returns (FeedResponse) {} + rpc get_feed_v1(FeedRequest) returns (FeedResponseV1) {} + rpc get_feed_clean(FeedRequest) returns (FeedResponse) {} + rpc get_feed_nsfw(FeedRequest) returns (FeedResponse) {} + rpc get_feed_coldstart(FeedRequest) returns (FeedResponse) {} +}