//
// DO NOT EDIT.
//
// Generated by the protocol buffer compiler.
// Source: service.proto
//

//
// Copyright 2018, gRPC Authors All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Dispatch
import Foundation
import SwiftGRPC
import SwiftProtobuf

internal protocol CompactTxStreamerGetLatestBlockCall: ClientCallUnary {}

fileprivate final class CompactTxStreamerGetLatestBlockCallBase: ClientCallUnaryBase<ChainSpec, BlockID>, CompactTxStreamerGetLatestBlockCall {
  override class var method: String { return "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetLatestBlock" }
}

internal protocol CompactTxStreamerGetBlockCall: ClientCallUnary {}

fileprivate final class CompactTxStreamerGetBlockCallBase: ClientCallUnaryBase<BlockID, CompactBlock>, CompactTxStreamerGetBlockCall {
  override class var method: String { return "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlock" }
}

internal protocol CompactTxStreamerGetBlockRangeCall: ClientCallServerStreaming {
  /// Do not call this directly, call `receive()` in the protocol extension below instead.
  func _receive(timeout: DispatchTime) throws -> CompactBlock?
  /// Call this to wait for a result. Nonblocking.
  func receive(completion: @escaping (ResultOrRPCError<CompactBlock?>) -> Void) throws
}

internal extension CompactTxStreamerGetBlockRangeCall {
  /// Call this to wait for a result. Blocking.
  func receive(timeout: DispatchTime = .distantFuture) throws -> CompactBlock? { return try self._receive(timeout: timeout) }
}

fileprivate final class CompactTxStreamerGetBlockRangeCallBase: ClientCallServerStreamingBase<BlockRange, CompactBlock>, CompactTxStreamerGetBlockRangeCall {
  override class var method: String { return "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetBlockRange" }
}

internal protocol CompactTxStreamerGetTransactionCall: ClientCallUnary {}

fileprivate final class CompactTxStreamerGetTransactionCallBase: ClientCallUnaryBase<TxFilter, RawTransaction>, CompactTxStreamerGetTransactionCall {
  override class var method: String { return "/cash.z.wallet.sdk.rpc.CompactTxStreamer/GetTransaction" }
}

internal protocol CompactTxStreamerSendTransactionCall: ClientCallUnary {}

fileprivate final class CompactTxStreamerSendTransactionCallBase: ClientCallUnaryBase<RawTransaction, SendResponse>, CompactTxStreamerSendTransactionCall {
  override class var method: String { return "/cash.z.wallet.sdk.rpc.CompactTxStreamer/SendTransaction" }
}


/// Instantiate CompactTxStreamerServiceClient, then call methods of this protocol to make API calls.
internal protocol CompactTxStreamerService: ServiceClient {
  /// Synchronous. Unary.
  func getLatestBlock(_ request: ChainSpec, metadata customMetadata: Metadata) throws -> BlockID
  /// Asynchronous. Unary.
  @discardableResult
  func getLatestBlock(_ request: ChainSpec, metadata customMetadata: Metadata, completion: @escaping (BlockID?, CallResult) -> Void) throws -> CompactTxStreamerGetLatestBlockCall

  /// Synchronous. Unary.
  func getBlock(_ request: BlockID, metadata customMetadata: Metadata) throws -> CompactBlock
  /// Asynchronous. Unary.
  @discardableResult
  func getBlock(_ request: BlockID, metadata customMetadata: Metadata, completion: @escaping (CompactBlock?, CallResult) -> Void) throws -> CompactTxStreamerGetBlockCall

  /// Asynchronous. Server-streaming.
  /// Send the initial message.
  /// Use methods on the returned object to get streamed responses.
  func getBlockRange(_ request: BlockRange, metadata customMetadata: Metadata, completion: ((CallResult) -> Void)?) throws -> CompactTxStreamerGetBlockRangeCall

  /// Synchronous. Unary.
  func getTransaction(_ request: TxFilter, metadata customMetadata: Metadata) throws -> RawTransaction
  /// Asynchronous. Unary.
  @discardableResult
  func getTransaction(_ request: TxFilter, metadata customMetadata: Metadata, completion: @escaping (RawTransaction?, CallResult) -> Void) throws -> CompactTxStreamerGetTransactionCall

  /// Synchronous. Unary.
  func sendTransaction(_ request: RawTransaction, metadata customMetadata: Metadata) throws -> SendResponse
  /// Asynchronous. Unary.
  @discardableResult
  func sendTransaction(_ request: RawTransaction, metadata customMetadata: Metadata, completion: @escaping (SendResponse?, CallResult) -> Void) throws -> CompactTxStreamerSendTransactionCall

}

internal extension CompactTxStreamerService {
  /// Synchronous. Unary.
  func getLatestBlock(_ request: ChainSpec) throws -> BlockID {
    return try self.getLatestBlock(request, metadata: self.metadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  func getLatestBlock(_ request: ChainSpec, completion: @escaping (BlockID?, CallResult) -> Void) throws -> CompactTxStreamerGetLatestBlockCall {
    return try self.getLatestBlock(request, metadata: self.metadata, completion: completion)
  }

  /// Synchronous. Unary.
  func getBlock(_ request: BlockID) throws -> CompactBlock {
    return try self.getBlock(request, metadata: self.metadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  func getBlock(_ request: BlockID, completion: @escaping (CompactBlock?, CallResult) -> Void) throws -> CompactTxStreamerGetBlockCall {
    return try self.getBlock(request, metadata: self.metadata, completion: completion)
  }

  /// Asynchronous. Server-streaming.
  func getBlockRange(_ request: BlockRange, completion: ((CallResult) -> Void)?) throws -> CompactTxStreamerGetBlockRangeCall {
    return try self.getBlockRange(request, metadata: self.metadata, completion: completion)
  }

  /// Synchronous. Unary.
  func getTransaction(_ request: TxFilter) throws -> RawTransaction {
    return try self.getTransaction(request, metadata: self.metadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  func getTransaction(_ request: TxFilter, completion: @escaping (RawTransaction?, CallResult) -> Void) throws -> CompactTxStreamerGetTransactionCall {
    return try self.getTransaction(request, metadata: self.metadata, completion: completion)
  }

  /// Synchronous. Unary.
  func sendTransaction(_ request: RawTransaction) throws -> SendResponse {
    return try self.sendTransaction(request, metadata: self.metadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  func sendTransaction(_ request: RawTransaction, completion: @escaping (SendResponse?, CallResult) -> Void) throws -> CompactTxStreamerSendTransactionCall {
    return try self.sendTransaction(request, metadata: self.metadata, completion: completion)
  }

}

internal final class CompactTxStreamerServiceClient: ServiceClientBase, CompactTxStreamerService {
  /// Synchronous. Unary.
  internal func getLatestBlock(_ request: ChainSpec, metadata customMetadata: Metadata) throws -> BlockID {
    return try CompactTxStreamerGetLatestBlockCallBase(channel)
      .run(request: request, metadata: customMetadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  internal func getLatestBlock(_ request: ChainSpec, metadata customMetadata: Metadata, completion: @escaping (BlockID?, CallResult) -> Void) throws -> CompactTxStreamerGetLatestBlockCall {
    return try CompactTxStreamerGetLatestBlockCallBase(channel)
      .start(request: request, metadata: customMetadata, completion: completion)
  }

  /// Synchronous. Unary.
  internal func getBlock(_ request: BlockID, metadata customMetadata: Metadata) throws -> CompactBlock {
    return try CompactTxStreamerGetBlockCallBase(channel)
      .run(request: request, metadata: customMetadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  internal func getBlock(_ request: BlockID, metadata customMetadata: Metadata, completion: @escaping (CompactBlock?, CallResult) -> Void) throws -> CompactTxStreamerGetBlockCall {
    return try CompactTxStreamerGetBlockCallBase(channel)
      .start(request: request, metadata: customMetadata, completion: completion)
  }

  /// Asynchronous. Server-streaming.
  /// Send the initial message.
  /// Use methods on the returned object to get streamed responses.
  internal func getBlockRange(_ request: BlockRange, metadata customMetadata: Metadata, completion: ((CallResult) -> Void)?) throws -> CompactTxStreamerGetBlockRangeCall {
    return try CompactTxStreamerGetBlockRangeCallBase(channel)
      .start(request: request, metadata: customMetadata, completion: completion)
  }

  /// Synchronous. Unary.
  internal func getTransaction(_ request: TxFilter, metadata customMetadata: Metadata) throws -> RawTransaction {
    return try CompactTxStreamerGetTransactionCallBase(channel)
      .run(request: request, metadata: customMetadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  internal func getTransaction(_ request: TxFilter, metadata customMetadata: Metadata, completion: @escaping (RawTransaction?, CallResult) -> Void) throws -> CompactTxStreamerGetTransactionCall {
    return try CompactTxStreamerGetTransactionCallBase(channel)
      .start(request: request, metadata: customMetadata, completion: completion)
  }

  /// Synchronous. Unary.
  internal func sendTransaction(_ request: RawTransaction, metadata customMetadata: Metadata) throws -> SendResponse {
    return try CompactTxStreamerSendTransactionCallBase(channel)
      .run(request: request, metadata: customMetadata)
  }
  /// Asynchronous. Unary.
  @discardableResult
  internal func sendTransaction(_ request: RawTransaction, metadata customMetadata: Metadata, completion: @escaping (SendResponse?, CallResult) -> Void) throws -> CompactTxStreamerSendTransactionCall {
    return try CompactTxStreamerSendTransactionCallBase(channel)
      .start(request: request, metadata: customMetadata, completion: completion)
  }

}

