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 models_GreeterServiceClient, then call methods of this protocol to make API calls. 27 public protocol models_GreeterClientProtocol: GRPCClient { 28 29 var serviceName: String { get } 30 31 var interceptors: models_GreeterClientInterceptorFactoryProtocol? { get } 32 33 func SayHello( 34 _ request: Message<models_HelloRequest> 35 , callOptions: CallOptions? 36 ) -> UnaryCall<Message<models_HelloRequest>, Message<models_HelloReply>> 37 38 func SayManyHellos( 39 _ request: Message<models_HelloRequest> 40 , callOptions: CallOptions?, 41 handler: @escaping (Message<models_HelloReply>) -> Void 42 ) -> ServerStreamingCall<Message<models_HelloRequest>, Message<models_HelloReply>> 43 44 } 45 46 extension models_GreeterClientProtocol { 47 48 public var serviceName: String { "models.Greeter" } 49 50 public func SayHello( 51 _ request: Message<models_HelloRequest> 52 , callOptions: CallOptions? = nil 53 ) -> UnaryCall<Message<models_HelloRequest>, Message<models_HelloReply>> { 54 return self.makeUnaryCall( 55 path: "/models.Greeter/SayHello", 56 request: request, 57 callOptions: callOptions ?? self.defaultCallOptions, 58 interceptors: self.interceptors?.makeSayHelloInterceptors() ?? [] 59 ) 60 } 61 62 public func SayManyHellos( 63 _ request: Message<models_HelloRequest> 64 , callOptions: CallOptions? = nil, 65 handler: @escaping (Message<models_HelloReply>) -> Void 66 ) -> ServerStreamingCall<Message<models_HelloRequest>, Message<models_HelloReply>> { 67 return self.makeServerStreamingCall( 68 path: "/models.Greeter/SayManyHellos", 69 request: request, 70 callOptions: callOptions ?? self.defaultCallOptions, 71 interceptors: self.interceptors?.makeSayManyHellosInterceptors() ?? [], 72 handler: handler 73 ) 74 } 75 } 76 77 public protocol models_GreeterClientInterceptorFactoryProtocol { 78 /// - Returns: Interceptors to use when invoking 'SayHello'. makeSayHelloInterceptorsnull79 func makeSayHelloInterceptors() -> [ClientInterceptor<Message<models_HelloRequest>, Message<models_HelloReply>>] 80 81 /// - Returns: Interceptors to use when invoking 'SayManyHellos'. 82 func makeSayManyHellosInterceptors() -> [ClientInterceptor<Message<models_HelloRequest>, Message<models_HelloReply>>] 83 84 } 85 86 public final class models_GreeterServiceClient: models_GreeterClientProtocol { 87 public let channel: GRPCChannel 88 public var defaultCallOptions: CallOptions 89 public var interceptors: models_GreeterClientInterceptorFactoryProtocol? 90 91 public init( 92 channel: GRPCChannel, 93 defaultCallOptions: CallOptions = CallOptions(), 94 interceptors: models_GreeterClientInterceptorFactoryProtocol? = nil 95 ) { 96 self.channel = channel 97 self.defaultCallOptions = defaultCallOptions 98 self.interceptors = interceptors 99 } 100 } 101 102 public protocol models_GreeterProvider: CallHandlerProvider { 103 var interceptors: models_GreeterServerInterceptorFactoryProtocol? { get } SayHellonull104 func SayHello(request: Message<models_HelloRequest>, context: StatusOnlyCallContext) -> EventLoopFuture<Message<models_HelloReply>> 105 func SayManyHellos(request: Message<models_HelloRequest>, context: StreamingResponseCallContext<Message<models_HelloReply>>) -> EventLoopFuture<GRPCStatus> 106 } 107 108 public extension models_GreeterProvider { 109 110 var serviceName: Substring { return "models.Greeter" } 111 112 func handle(method name: Substring, context: CallHandlerContext) -> GRPCServerHandlerProtocol? { 113 switch name { 114 case "SayHello": 115 return UnaryServerHandler( 116 context: context, 117 requestDeserializer: GRPCPayloadDeserializer<Message<models_HelloRequest>>(), 118 responseSerializer: GRPCPayloadSerializer<Message<models_HelloReply>>(), 119 interceptors: self.interceptors?.makeSayHelloInterceptors() ?? [], 120 userFunction: self.SayHello(request:context:)) 121 122 case "SayManyHellos": 123 return ServerStreamingServerHandler( 124 context: context, 125 requestDeserializer: GRPCPayloadDeserializer<Message<models_HelloRequest>>(), 126 responseSerializer: GRPCPayloadSerializer<Message<models_HelloReply>>(), 127 interceptors: self.interceptors?.makeSayManyHellosInterceptors() ?? [], 128 userFunction: self.SayManyHellos(request:context:)) 129 130 default: return nil; 131 } 132 } 133 134 } 135 136 public protocol models_GreeterServerInterceptorFactoryProtocol { 137 /// - Returns: Interceptors to use when handling 'SayHello'. 138 /// Defaults to calling `self.makeInterceptors()`. makeSayHelloInterceptorsnull139 func makeSayHelloInterceptors() -> [ServerInterceptor<Message<models_HelloRequest>, Message<models_HelloReply>>] 140 141 /// - Returns: Interceptors to use when handling 'SayManyHellos'. 142 /// Defaults to calling `self.makeInterceptors()`. 143 func makeSayManyHellosInterceptors() -> [ServerInterceptor<Message<models_HelloRequest>, Message<models_HelloReply>>] 144 145 } 146