// Generated GRPC code for FlatBuffers swift!
/// The following code is generated by the Flatbuffers library which might not be in sync with grpc-swift
/// in case of an issue please open github issue, though it would be maintained

// swiftlint:disable all
// swiftformat:disable all

#if !os(Windows) && compiler(>=6.0)
import FlatBuffers
import Foundation
import GRPCCore
import GRPCNIOTransportCore


/// Usage: instantiate models.GreeterServiceClient, then call methods of this protocol to make API calls.
@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension FlatBuffersMessageSerializer: MessageSerializer {
  public func serialize<Bytes>(_ message: Message) throws -> Bytes where Bytes : GRPCCore.GRPCContiguousBytes {
    do {
      return try self.serialize(message: message) { GRPCNIOTransportBytes($0) } as! Bytes
    } catch let error {
      throw RPCError(
        code: .invalidArgument,
        message: "Can't serialize message",
        cause: error
      )
    }
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension FlatBuffersMessageDeserializer: MessageDeserializer {
  public func deserialize<Bytes>(_ serializedMessageBytes: Bytes) throws -> Message where Bytes : GRPCCore.GRPCContiguousBytes {
    do {
      return try serializedMessageBytes.withUnsafeBytes {
        try self.deserialize(pointer: $0)
      }
    } catch let error {
      throw RPCError(
        code: .invalidArgument,
        message: "Can't Decode message of type \(Message.self)",
        cause: error
      )
    }
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
public enum models_Greeter: Sendable {
  public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter")
  public enum Method: Sendable {
    public enum Get: Sendable {
      public typealias Input = FlatBufferBuilder
      public typealias Output = models_HelloResponse
      public static let descriptor = GRPCCore.MethodDescriptor(
        service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
        method: "Get"
      )
    }
    public enum Collect: Sendable {
      public typealias Input = FlatBufferBuilder
      public typealias Output = models_HelloResponse
      public static let descriptor = GRPCCore.MethodDescriptor(
        service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
        method: "Collect"
      )
    }
    public enum Expand: Sendable {
      public typealias Input = FlatBufferBuilder
      public typealias Output = models_HelloResponse
      public static let descriptor = GRPCCore.MethodDescriptor(
        service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
        method: "Expand"
      )
    }
    public enum Update: Sendable {
      public typealias Input = FlatBufferBuilder
      public typealias Output = models_HelloResponse
      public static let descriptor = GRPCCore.MethodDescriptor(
        service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter"),
        method: "Update"
      )
    }
    public static let descriptors: [GRPCCore.MethodDescriptor] = [
      Get.descriptor,
      Collect.descriptor,
      Expand.descriptor,
      Update.descriptor,
    ]
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension GRPCCore.ServiceDescriptor {
  public static let models_Greeter = GRPCCore.ServiceDescriptor(fullyQualifiedService: "models.Greeter")
}

// MARK: models.Greeter Server

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter {
  public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
    func Get(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Collect(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Expand(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Update(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
  }
  
  public protocol ServiceProtocol: models_Greeter.StreamingServiceProtocol {
    func Get(
      request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Collect(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Expand(
      request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
    func Update(
      request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>
    
  }
  
  public protocol SimpleServiceProtocol: models_Greeter.ServiceProtocol {
    func Get(
      request: GRPCMessage<models_HelloResponse>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCMessage<models_HelloResponse>
    
    func Collect(
      request: GRPCCore.RPCAsyncSequence<GRPCMessage<models_HelloResponse>, any Swift.Error>,
      context: GRPCCore.ServerContext
    ) async throws -> GRPCMessage<models_HelloResponse>
    
    func Expand(
      request: GRPCMessage<models_HelloResponse>,
      response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws
    
    func Update(
      request: GRPCCore.RPCAsyncSequence<GRPCMessage<models_HelloResponse>, any Swift.Error>,
      response: GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>,
      context: GRPCCore.ServerContext
    ) async throws
    
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter.StreamingServiceProtocol {
  public func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
    router.registerHandler(
      forMethod: models_Greeter.Method.Get.descriptor,
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      handler: { request, context in
        try await self.Get(
          request: request,
          context: context
        )
      }
    )
    router.registerHandler(
      forMethod: models_Greeter.Method.Collect.descriptor,
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      handler: { request, context in
        try await self.Collect(
          request: request,
          context: context
        )
      }
    )
    router.registerHandler(
      forMethod: models_Greeter.Method.Expand.descriptor,
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      handler: { request, context in
        try await self.Expand(
          request: request,
          context: context
        )
      }
    )
    router.registerHandler(
      forMethod: models_Greeter.Method.Update.descriptor,
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      handler: { request, context in
        try await self.Update(
          request: request,
          context: context
        )
      }
    )
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter.ServiceProtocol {
  public func Get(
    request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
    let response = try await self.Get(
      request: GRPCCore.ServerRequest(stream: request),
      context: context
    )
    return GRPCCore.StreamingServerResponse(single: response)
  }
  public func Collect(
    request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
    let response = try await self.Collect(
      request: request,
      context: context
    )
    return GRPCCore.StreamingServerResponse(single: response)
  }
  public func Expand(
    request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
    let response = try await self.Expand(
      request: GRPCCore.ServerRequest(stream: request),
      context: context
    )
    return response
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter.SimpleServiceProtocol {
  public func Get(
    request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>> {
    return GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>(
      message: try await self.Get(
        request: request.message,
        context: context
      ),
      metadata: [:]
    )
  }
  public func Collect(
    request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>> {
    return GRPCCore.ServerResponse<GRPCMessage<models_HelloResponse>>(
      message: try await self.Collect(
        request: request.messages,
        context: context
      ),
      metadata: [:]
    )
  }
  public func Expand(
    request: GRPCCore.ServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
    return GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>(
      metadata: [:],
      producer: { writer in
        try await self.Expand(
          request: request.message,
          response: writer,
          context: context
        )
        return [:]
      }
    )
  }
  public func Update(
    request: GRPCCore.StreamingServerRequest<GRPCMessage<models_HelloResponse>>,
    context: GRPCCore.ServerContext
  ) async throws -> GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>> {
    return GRPCCore.StreamingServerResponse<GRPCMessage<models_HelloResponse>>(
      metadata: [:],
      producer: { writer in
        try await self.Update(
          request: request.messages,
          response: writer,
          context: context
        )
        return [:]
      }
    )
  }
}


// MARK: models.Greeter Client

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter {
  public protocol ClientProtocol: Sendable {
    func Get<Result>(
      request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable
    
    func Collect<Result>(
      request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable
    
    func Expand<Result>(
      request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable
    
    func Update<Result>(
      request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable
    
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter {
  public struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
    private let client: GRPCCore.GRPCClient<Transport>
    
    public init(wrapping client: GRPCCore.GRPCClient<Transport>) {
      self.client = client
    }
    
    public func Get<Result>(
      request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions = .defaults,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
    ) async throws -> Result where Result: Sendable {
      try await self.client.unary(
        request: request,
        descriptor: models_Greeter.Method.Get.descriptor,
        serializer: serializer,
        deserializer: deserializer,
        options: options,
        onResponse: handleResponse
      )
    }
    
    public func Collect<Result>(
      request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions = .defaults,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
    ) async throws -> Result where Result: Sendable {
      try await self.client.clientStreaming(
        request: request,
        descriptor: models_Greeter.Method.Collect.descriptor,
        serializer: serializer,
        deserializer: deserializer,
        options: options,
        onResponse: handleResponse
      )
    }
    
    public func Expand<Result>(
      request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions = .defaults,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable {
      try await self.client.serverStreaming(
        request: request,
        descriptor: models_Greeter.Method.Expand.descriptor,
        serializer: serializer,
        deserializer: deserializer,
        options: options,
        onResponse: handleResponse
      )
    }
    
    public func Update<Result>(
      request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
      serializer: some GRPCCore.MessageSerializer<GRPCMessage<models_HelloResponse>>,
      deserializer: some GRPCCore.MessageDeserializer<GRPCMessage<models_HelloResponse>>,
      options: GRPCCore.CallOptions = .defaults,
      onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
    ) async throws -> Result where Result: Sendable {
      try await self.client.bidirectionalStreaming(
        request: request,
        descriptor: models_Greeter.Method.Update.descriptor,
        serializer: serializer,
        deserializer: deserializer,
        options: options,
        onResponse: handleResponse
      )
    }
    
  }
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter.ClientProtocol {
  public func Get<Result>(
    request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
  ) async throws -> Result where Result: Sendable {
    try await self.Get(
      request: request,
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Collect<Result>(
    request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { response in try response.message }
  ) async throws -> Result where Result: Sendable {
    try await self.Collect(
      request: request,
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Expand<Result>(
    request: GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>,
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
  ) async throws -> Result where Result: Sendable {
    try await self.Expand(
      request: request,
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Update<Result>(
    request: GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>,
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
  ) async throws -> Result where Result: Sendable {
    try await self.Update(
      request: request,
      serializer: FlatBuffersMessageSerializer<GRPCMessage<models_HelloResponse>>(),
      deserializer: FlatBuffersMessageDeserializer<GRPCMessage<models_HelloResponse>>(),
      options: options,
      onResponse: handleResponse
    )
  }
  
}

@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
extension models_Greeter.ClientProtocol {
  public func Get<Result>(
    _ message: GRPCMessage<models_HelloResponse>,
    metadata: GRPCCore.Metadata = [:],
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { try $0.message }
  ) async throws -> Result where Result: Sendable {
    let request = GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>(
      message: message,
      metadata: metadata
    )
    return try await self.Get(
      request: request,
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Collect<Result>(
    metadata: GRPCCore.Metadata = [:],
    options: GRPCCore.CallOptions = .defaults,
    requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>) async throws -> Void,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result = { try $0.message }
  ) async throws -> Result where Result: Sendable {
    let request = GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>(
      metadata: metadata,
      producer: producer
    )
    return try await self.Collect(
      request: request,
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Expand<Result>(
    _ message: GRPCMessage<models_HelloResponse>,
    metadata: GRPCCore.Metadata = [:],
    options: GRPCCore.CallOptions = .defaults,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
  ) async throws -> Result where Result: Sendable {
    let request = GRPCCore.ClientRequest<GRPCMessage<models_HelloResponse>>(
      message: message,
      metadata: metadata
    )
    return try await self.Expand(
      request: request,
      options: options,
      onResponse: handleResponse
    )
  }
  
  public func Update<Result>(
    metadata: GRPCCore.Metadata = [:],
    options: GRPCCore.CallOptions = .defaults,
    requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter<GRPCMessage<models_HelloResponse>>) async throws -> Void,
    onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse<GRPCMessage<models_HelloResponse>>) async throws -> Result
  ) async throws -> Result where Result: Sendable {
    let request = GRPCCore.StreamingClientRequest<GRPCMessage<models_HelloResponse>>(
      metadata: metadata,
      producer: producer
    )
    return try await self.Update(
      request: request,
      options: options,
      onResponse: handleResponse
    )
  }
  
}

#endif

