// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: cosmos/base/query/v1beta1/pagination.proto
//
// For information on using the generated types, please see the documentation:
//   https://github.com/apple/swift-protobuf/

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that you are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

/// PageRequest is to be embedded in gRPC request messages for efficient
/// pagination. Ex:
///
///  message SomeRequest {
///          Foo some_parameter = 1;
///          PageRequest pagination = 2;
///  }
public struct Cosmos_Base_Query_V1beta1_PageRequest {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// key is a value returned in PageResponse.next_key to begin
  /// querying the next page most efficiently. Only one of offset or key
  /// should be set.
  public var key: Data = Data()

  /// offset is a numeric offset that can be used when key is unavailable.
  /// It is less efficient than using key. Only one of offset or key should
  /// be set.
  public var offset: UInt64 = 0

  /// limit is the total number of results to be returned in the result page.
  /// If left empty it will default to a value to be set by each app.
  public var limit: UInt64 = 0

  /// count_total is set to true  to indicate that the result set should include
  /// a count of the total number of items available for pagination in UIs.
  /// count_total is only respected when offset is used. It is ignored when key
  /// is set.
  public var countTotal: Bool = false

  /// reverse is set to true if results are to be returned in the descending order.
  public var reverse: Bool = false

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

/// PageResponse is to be embedded in gRPC response messages where the
/// corresponding request message has used PageRequest.
///
///  message SomeResponse {
///          repeated Bar results = 1;
///          PageResponse page = 2;
///  }
public struct Cosmos_Base_Query_V1beta1_PageResponse {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// next_key is the key to be passed to PageRequest.key to
  /// query the next page most efficiently
  public var nextKey: Data = Data()

  /// total is total number of results available if PageRequest.count_total
  /// was set, its value is undefined otherwise
  public var total: UInt64 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "cosmos.base.query.v1beta1"

extension Cosmos_Base_Query_V1beta1_PageRequest: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".PageRequest"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "key"),
    2: .same(proto: "offset"),
    3: .same(proto: "limit"),
    4: .standard(proto: "count_total"),
    5: .same(proto: "reverse"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularBytesField(value: &self.key) }()
      case 2: try { try decoder.decodeSingularUInt64Field(value: &self.offset) }()
      case 3: try { try decoder.decodeSingularUInt64Field(value: &self.limit) }()
      case 4: try { try decoder.decodeSingularBoolField(value: &self.countTotal) }()
      case 5: try { try decoder.decodeSingularBoolField(value: &self.reverse) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.key.isEmpty {
      try visitor.visitSingularBytesField(value: self.key, fieldNumber: 1)
    }
    if self.offset != 0 {
      try visitor.visitSingularUInt64Field(value: self.offset, fieldNumber: 2)
    }
    if self.limit != 0 {
      try visitor.visitSingularUInt64Field(value: self.limit, fieldNumber: 3)
    }
    if self.countTotal != false {
      try visitor.visitSingularBoolField(value: self.countTotal, fieldNumber: 4)
    }
    if self.reverse != false {
      try visitor.visitSingularBoolField(value: self.reverse, fieldNumber: 5)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Cosmos_Base_Query_V1beta1_PageRequest, rhs: Cosmos_Base_Query_V1beta1_PageRequest) -> Bool {
    if lhs.key != rhs.key {return false}
    if lhs.offset != rhs.offset {return false}
    if lhs.limit != rhs.limit {return false}
    if lhs.countTotal != rhs.countTotal {return false}
    if lhs.reverse != rhs.reverse {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Cosmos_Base_Query_V1beta1_PageResponse: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".PageResponse"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .standard(proto: "next_key"),
    2: .same(proto: "total"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      // The use of inline closures is to circumvent an issue where the compiler
      // allocates stack space for every case branch when no optimizations are
      // enabled. https://github.com/apple/swift-protobuf/issues/1034
      switch fieldNumber {
      case 1: try { try decoder.decodeSingularBytesField(value: &self.nextKey) }()
      case 2: try { try decoder.decodeSingularUInt64Field(value: &self.total) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.nextKey.isEmpty {
      try visitor.visitSingularBytesField(value: self.nextKey, fieldNumber: 1)
    }
    if self.total != 0 {
      try visitor.visitSingularUInt64Field(value: self.total, fieldNumber: 2)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Cosmos_Base_Query_V1beta1_PageResponse, rhs: Cosmos_Base_Query_V1beta1_PageResponse) -> Bool {
    if lhs.nextKey != rhs.nextKey {return false}
    if lhs.total != rhs.total {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
