1 // Generated GRPC code for FlatBuffers swift! 2 /// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift 3 /// in case of an issue please open github issue, though it would be maintained 4 5 // swiftlint:disable all 6 // swiftformat:disable all 7 8 import Foundation 9 import GRPC 10 import NIO 11 import NIOHTTP1 12 import FlatBuffers 13 14 public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {} 15 public extension GRPCFlatBufPayload { 16 init(serializedByteBuffer: inout NIO.ByteBuffer) throws { 17 self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes)) 18 } serializenull19 func serialize(into buffer: inout NIO.ByteBuffer) throws { 20 let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size)) 21 buffer.writeBytes(buf) 22 } 23 } 24 extension Message: GRPCFlatBufPayload {} 25 26 /// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls. 27 public protocol MyGame_Example_MonsterStorageClientProtocol: GRPCClient { 28 29 var serviceName: String { get } 30 31 var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? { get } 32 33 func Store( 34 _ request: Message<MyGame_Example_Monster> 35 , callOptions: CallOptions? 36 ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> 37 38 func Retrieve( 39 _ request: Message<MyGame_Example_Stat> 40 , callOptions: CallOptions?, 41 handler: @escaping (Message<MyGame_Example_Monster>) -> Void 42 ) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> 43 44 func GetMaxHitPoint( 45 callOptions: CallOptions? 46 ) -> ClientStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> 47 48 func GetMinMaxHitPoints( 49 callOptions: CallOptions?, 50 handler: @escaping (Message<MyGame_Example_Stat> ) -> Void 51 ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> 52 53 } 54 55 extension MyGame_Example_MonsterStorageClientProtocol { 56 57 public var serviceName: String { "MyGame.Example.MonsterStorage" } 58 59 public func Store( 60 _ request: Message<MyGame_Example_Monster> 61 , callOptions: CallOptions? = nil 62 ) -> UnaryCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> { 63 return self.makeUnaryCall( 64 path: "/MyGame.Example.MonsterStorage/Store", 65 request: request, 66 callOptions: callOptions ?? self.defaultCallOptions, 67 interceptors: self.interceptors?.makeStoreInterceptors() ?? [] 68 ) 69 } 70 71 public func Retrieve( 72 _ request: Message<MyGame_Example_Stat> 73 , callOptions: CallOptions? = nil, 74 handler: @escaping (Message<MyGame_Example_Monster>) -> Void 75 ) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> { 76 return self.makeServerStreamingCall( 77 path: "/MyGame.Example.MonsterStorage/Retrieve", 78 request: request, 79 callOptions: callOptions ?? self.defaultCallOptions, 80 interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [], 81 handler: handler 82 ) 83 } 84 85 public func GetMaxHitPoint( 86 callOptions: CallOptions? = nil 87 ) -> ClientStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> { 88 return self.makeClientStreamingCall( 89 path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint", 90 callOptions: callOptions ?? self.defaultCallOptions, 91 interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? [] 92 ) 93 } 94 95 public func GetMinMaxHitPoints( 96 callOptions: CallOptions? = nil, 97 handler: @escaping (Message<MyGame_Example_Stat> ) -> Void 98 ) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> { 99 return self.makeBidirectionalStreamingCall( 100 path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints", 101 callOptions: callOptions ?? self.defaultCallOptions, 102 interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [], 103 handler: handler 104 ) 105 } 106 } 107 108 public protocol MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol { 109 /// - Returns: Interceptors to use when invoking 'Store'. makeStoreInterceptorsnull110 func makeStoreInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 111 112 /// - Returns: Interceptors to use when invoking 'Retrieve'. 113 func makeRetrieveInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>] 114 115 /// - Returns: Interceptors to use when invoking 'GetMaxHitPoint'. 116 func makeGetMaxHitPointInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 117 118 /// - Returns: Interceptors to use when invoking 'GetMinMaxHitPoints'. 119 func makeGetMinMaxHitPointsInterceptors() -> [ClientInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 120 121 } 122 123 public final class MyGame_Example_MonsterStorageServiceClient: MyGame_Example_MonsterStorageClientProtocol { 124 public let channel: GRPCChannel 125 public var defaultCallOptions: CallOptions 126 public var interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? 127 128 public init( 129 channel: GRPCChannel, 130 defaultCallOptions: CallOptions = CallOptions(), 131 interceptors: MyGame_Example_MonsterStorageClientInterceptorFactoryProtocol? = nil 132 ) { 133 self.channel = channel 134 self.defaultCallOptions = defaultCallOptions 135 self.interceptors = interceptors 136 } 137 } 138 139 public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider { 140 var interceptors: MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol? { get } Storenull141 func Store(request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>> 142 func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus> 143 func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void> 144 func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void> 145 } 146 147 public extension MyGame_Example_MonsterStorageProvider { 148 149 var serviceName: Substring { return "MyGame.Example.MonsterStorage" } 150 151 func handle(method name: Substring, context: CallHandlerContext) -> GRPCServerHandlerProtocol? { 152 switch name { 153 case "Store": 154 return UnaryServerHandler( 155 context: context, 156 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(), 157 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(), 158 interceptors: self.interceptors?.makeStoreInterceptors() ?? [], 159 userFunction: self.Store(request:context:)) 160 161 case "Retrieve": 162 return ServerStreamingServerHandler( 163 context: context, 164 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Stat>>(), 165 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Monster>>(), 166 interceptors: self.interceptors?.makeRetrieveInterceptors() ?? [], 167 userFunction: self.Retrieve(request:context:)) 168 169 case "GetMaxHitPoint": 170 return ClientStreamingServerHandler( 171 context: context, 172 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(), 173 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(), 174 interceptors: self.interceptors?.makeGetMaxHitPointInterceptors() ?? [], 175 observerFactory: self.GetMaxHitPoint(context:)) 176 177 case "GetMinMaxHitPoints": 178 return BidirectionalStreamingServerHandler( 179 context: context, 180 requestDeserializer: GRPCPayloadDeserializer<Message<MyGame_Example_Monster>>(), 181 responseSerializer: GRPCPayloadSerializer<Message<MyGame_Example_Stat>>(), 182 interceptors: self.interceptors?.makeGetMinMaxHitPointsInterceptors() ?? [], 183 observerFactory: self.GetMinMaxHitPoints(context:)) 184 185 default: return nil; 186 } 187 } 188 189 } 190 191 public protocol MyGame_Example_MonsterStorageServerInterceptorFactoryProtocol { 192 /// - Returns: Interceptors to use when handling 'Store'. 193 /// Defaults to calling `self.makeInterceptors()`. makeStoreInterceptorsnull194 func makeStoreInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 195 196 /// - Returns: Interceptors to use when handling 'Retrieve'. 197 /// Defaults to calling `self.makeInterceptors()`. 198 func makeRetrieveInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>] 199 200 /// - Returns: Interceptors to use when handling 'GetMaxHitPoint'. 201 /// Defaults to calling `self.makeInterceptors()`. 202 func makeGetMaxHitPointInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 203 204 /// - Returns: Interceptors to use when handling 'GetMinMaxHitPoints'. 205 /// Defaults to calling `self.makeInterceptors()`. 206 func makeGetMinMaxHitPointsInterceptors() -> [ServerInterceptor<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>] 207 208 } 209