blob: 414a816d6f93478525d44c48ded26be6a0e515d3 [file] [log] [blame]
Austin Schuh272c6132020-11-14 16:37:52 -08001// 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
Austin Schuh58b9b472020-11-25 19:12:44 -08004
5// swiftlint:disable all
6// swiftformat:disable all
7
Austin Schuh272c6132020-11-14 16:37:52 -08008import Foundation
9import GRPC
10import NIO
11import NIOHTTP1
12import FlatBuffers
13
14public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
15public extension GRPCFlatBufPayload {
Austin Schuh58b9b472020-11-25 19:12:44 -080016 init(serializedByteBuffer: inout NIO.ByteBuffer) throws {
17 self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes))
18 }
19 func serialize(into buffer: inout NIO.ByteBuffer) throws {
20 let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size))
21 buffer.writeBytes(buf)
22 }
Austin Schuh272c6132020-11-14 16:37:52 -080023}
24extension Message: GRPCFlatBufPayload {}
25
26/// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls.
27public protocol MyGame_Example_MonsterStorageService {
Austin Schuh58b9b472020-11-25 19:12:44 -080028 func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions?) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>>
29 func Retrieve(_ request: Message<MyGame_Example_Stat>, callOptions: CallOptions?, handler: @escaping (Message<MyGame_Example_Monster>) -> Void) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>>
30 func GetMaxHitPoint(callOptions: CallOptions?) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>>
31 func GetMinMaxHitPoints(callOptions: CallOptions?, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
Austin Schuh272c6132020-11-14 16:37:52 -080032}
33
34public final class MyGame_Example_MonsterStorageServiceClient: GRPCClient, MyGame_Example_MonsterStorageService {
Austin Schuh58b9b472020-11-25 19:12:44 -080035 public let channel: GRPCChannel
36 public var defaultCallOptions: CallOptions
Austin Schuh272c6132020-11-14 16:37:52 -080037
Austin Schuh58b9b472020-11-25 19:12:44 -080038 public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
39 self.channel = channel
40 self.defaultCallOptions = defaultCallOptions
41 }
Austin Schuh272c6132020-11-14 16:37:52 -080042
Austin Schuh58b9b472020-11-25 19:12:44 -080043 public func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions? = nil) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> {
44 return self.makeUnaryCall(path: "/MyGame.Example.MonsterStorage/Store", request: request, callOptions: callOptions ?? self.defaultCallOptions)
45 }
Austin Schuh272c6132020-11-14 16:37:52 -080046
Austin Schuh58b9b472020-11-25 19:12:44 -080047 public func Retrieve(_ request: Message<MyGame_Example_Stat>, callOptions: CallOptions? = nil, handler: @escaping (Message<MyGame_Example_Monster>) -> Void) -> ServerStreamingCall<Message<MyGame_Example_Stat>, Message<MyGame_Example_Monster>> {
48 return self.makeServerStreamingCall(path: "/MyGame.Example.MonsterStorage/Retrieve", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler)
49 }
Austin Schuh272c6132020-11-14 16:37:52 -080050
Austin Schuh58b9b472020-11-25 19:12:44 -080051 public func GetMaxHitPoint(callOptions: CallOptions? = nil) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> {
52 return self.makeClientStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint", callOptions: callOptions ?? self.defaultCallOptions)
53 }
Austin Schuh272c6132020-11-14 16:37:52 -080054
Austin Schuh58b9b472020-11-25 19:12:44 -080055 public func GetMinMaxHitPoints(callOptions: CallOptions? = nil, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
56 return self.makeBidirectionalStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints", callOptions: callOptions ?? self.defaultCallOptions, handler: handler)
57 }
Austin Schuh272c6132020-11-14 16:37:52 -080058}
59
60public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider {
Austin Schuh58b9b472020-11-25 19:12:44 -080061 func Store(_ request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>>
62 func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus>
63 func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
64 func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
Austin Schuh272c6132020-11-14 16:37:52 -080065}
66
67public extension MyGame_Example_MonsterStorageProvider {
68
Austin Schuh58b9b472020-11-25 19:12:44 -080069 var serviceName: Substring { return "MyGame.Example.MonsterStorage" }
Austin Schuh272c6132020-11-14 16:37:52 -080070
Austin Schuh58b9b472020-11-25 19:12:44 -080071 func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
72 switch methodName {
73 case "Store":
74 return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
75 return { request in
76 self.Store(request, context: context)
77 }
78 }
79 case "Retrieve":
80 return CallHandlerFactory.makeServerStreaming(callHandlerContext: callHandlerContext) { context in
81 return { request in
82 self.Retrieve(request: request, context: context)
83 }
84 }
85 case "GetMaxHitPoint":
86 return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in
87 self.GetMaxHitPoint(context: context)
88 }
89 case "GetMinMaxHitPoints":
90 return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in
91 self.GetMinMaxHitPoints(context: context)
92 }
93 default: return nil;
94 }
95 }
Austin Schuh272c6132020-11-14 16:37:52 -080096
97}