blob: b2f3ff27c23065959708a4de9a6d313e24b4674b [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
4import Foundation
5import GRPC
6import NIO
7import NIOHTTP1
8import FlatBuffers
9
10public protocol GRPCFlatBufPayload: GRPCPayload, FlatBufferGRPCMessage {}
11public extension GRPCFlatBufPayload {
12 init(serializedByteBuffer: inout NIO.ByteBuffer) throws {
13 self.init(byteBuffer: FlatBuffers.ByteBuffer(contiguousBytes: serializedByteBuffer.readableBytesView, count: serializedByteBuffer.readableBytes))
14 }
15 func serialize(into buffer: inout NIO.ByteBuffer) throws {
16 let buf = UnsafeRawBufferPointer(start: self.rawPointer, count: Int(self.size))
17 buffer.writeBytes(buf)
18 }
19}
20extension Message: GRPCFlatBufPayload {}
21
22/// Usage: instantiate MyGame_Example_MonsterStorageServiceClient, then call methods of this protocol to make API calls.
23public protocol MyGame_Example_MonsterStorageService {
24 func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions?) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>>
25 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>>
26 func GetMaxHitPoint(callOptions: CallOptions?) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>>
27 func GetMinMaxHitPoints(callOptions: CallOptions?, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>>
28}
29
30public final class MyGame_Example_MonsterStorageServiceClient: GRPCClient, MyGame_Example_MonsterStorageService {
31 public let channel: GRPCChannel
32 public var defaultCallOptions: CallOptions
33
34 public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
35 self.channel = channel
36 self.defaultCallOptions = defaultCallOptions
37 }
38
39 public func Store(_ request: Message<MyGame_Example_Monster>, callOptions: CallOptions? = nil) -> UnaryCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> {
40 return self.makeUnaryCall(path: "/MyGame.Example.MonsterStorage/Store", request: request, callOptions: callOptions ?? self.defaultCallOptions)
41 }
42
43 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>> {
44 return self.makeServerStreamingCall(path: "/MyGame.Example.MonsterStorage/Retrieve", request: request, callOptions: callOptions ?? self.defaultCallOptions, handler: handler)
45 }
46
47 public func GetMaxHitPoint(callOptions: CallOptions? = nil) -> ClientStreamingCall<Message<MyGame_Example_Monster>,Message<MyGame_Example_Stat>> {
48 return self.makeClientStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMaxHitPoint", callOptions: callOptions ?? self.defaultCallOptions)
49 }
50
51 public func GetMinMaxHitPoints(callOptions: CallOptions? = nil, handler: @escaping (Message<MyGame_Example_Stat>) -> Void) -> BidirectionalStreamingCall<Message<MyGame_Example_Monster>, Message<MyGame_Example_Stat>> {
52 return self.makeBidirectionalStreamingCall(path: "/MyGame.Example.MonsterStorage/GetMinMaxHitPoints", callOptions: callOptions ?? self.defaultCallOptions, handler: handler)
53 }
54}
55
56public protocol MyGame_Example_MonsterStorageProvider: CallHandlerProvider {
57 func Store(_ request: Message<MyGame_Example_Monster>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<MyGame_Example_Stat>>
58 func Retrieve(request: Message<MyGame_Example_Stat>, context: StreamingResponseCallContext<Message<MyGame_Example_Monster>>) -> EventLoopFuture<GRPCStatus>
59 func GetMaxHitPoint(context: UnaryResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
60 func GetMinMaxHitPoints(context: StreamingResponseCallContext<Message<MyGame_Example_Stat>>) -> EventLoopFuture<(StreamEvent<Message<MyGame_Example_Monster>>) -> Void>
61}
62
63public extension MyGame_Example_MonsterStorageProvider {
64
65 var serviceName: Substring { return "MyGame.Example.MonsterStorage" }
66
67 func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
68 switch methodName {
69 case "Store":
70 return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
71 return { request in
72 self.Store(request, context: context)
73 }
74 }
75 case "Retrieve":
76 return CallHandlerFactory.makeServerStreaming(callHandlerContext: callHandlerContext) { context in
77 return { request in
78 self.Retrieve(request: request, context: context)
79 }
80 }
81 case "GetMaxHitPoint":
82 return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in
83 self.GetMaxHitPoint(context: context)
84 }
85 case "GetMinMaxHitPoints":
86 return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in
87 self.GetMinMaxHitPoints(context: context)
88 }
89 default: return nil;
90 }
91 }
92
93}
94
95