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

// This source file is part of the Swift.org open source project
//
// Copyright (c) 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

import Foundation
import SwiftProtobuf

import TSFCAS

// 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
}

/// The reference to a rule evaluation key. This is used for 2 purposes: to avoid having a large rule evaluation key
/// since the configured target might be large in size (potentially avoidable with proper CAS architecture) and to use
/// as a reference for artifact ownership. Artifacts then get a reference to the rule evaluation that registered them in
/// order to find the action that generates it. Initially this was solved by uploading the action itself into the CAS and
/// having the artifact ownership point to that, but there was a cycle issue when uploading the action keys as some input
/// artifacts had not been updated yet. With this approach, artifacts get the ownership during action registration,
/// avoiding that particular issue.
public struct LLBRuleEvaluationKeyID {
  // 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.

  /// The data ID for the rule evaluation key.
  public var ruleEvaluationKeyID: TSFCAS.LLBDataID {
    get {return _ruleEvaluationKeyID ?? TSFCAS.LLBDataID()}
    set {_ruleEvaluationKeyID = newValue}
  }
  /// Returns true if `ruleEvaluationKeyID` has been explicitly set.
  public var hasRuleEvaluationKeyID: Bool {return self._ruleEvaluationKeyID != nil}
  /// Clears the value of `ruleEvaluationKeyID`. Subsequent reads from it will return its default value.
  public mutating func clearRuleEvaluationKeyID() {self._ruleEvaluationKeyID = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _ruleEvaluationKeyID: TSFCAS.LLBDataID? = nil
}

/// A RuleEvaluationKey represents the evaluation of the rule for a particular configured target. The evaluation of a
/// rule results in a list of providers which represent the interface that a configured target offers to dependencies.
/// This is different from EvaluatedTargetKey in that it is a scoped down version of evaluation, since it does not
/// require the presence of the rootID field, which effectively changes with any change in the workspace. The digest of
/// a RuleEvaluationKey should be stable to the _contents_ of a configured target. This means that if a source file
/// changed, it should not invalidate the cache of a RuleEvaluationKey.
public struct LLBRuleEvaluationKey {
  // 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.

  /// The label for the configured target being evaluated.
  public var label: LLBLabel {
    get {return _label ?? LLBLabel()}
    set {_label = newValue}
  }
  /// Returns true if `label` has been explicitly set.
  public var hasLabel: Bool {return self._label != nil}
  /// Clears the value of `label`. Subsequent reads from it will return its default value.
  public mutating func clearLabel() {self._label = nil}

  /// The configured target value to evaluate in the rule.
  public var configuredTargetValue: LLBConfiguredTargetValue {
    get {return _configuredTargetValue ?? LLBConfiguredTargetValue()}
    set {_configuredTargetValue = newValue}
  }
  /// Returns true if `configuredTargetValue` has been explicitly set.
  public var hasConfiguredTargetValue: Bool {return self._configuredTargetValue != nil}
  /// Clears the value of `configuredTargetValue`. Subsequent reads from it will return its default value.
  public mutating func clearConfiguredTargetValue() {self._configuredTargetValue = nil}

  /// The configuration key under which this should be evaluated under. The ConfigurationValue fragments will be made
  /// available in the rule context.
  public var configurationKey: LLBConfigurationKey {
    get {return _configurationKey ?? LLBConfigurationKey()}
    set {_configurationKey = newValue}
  }
  /// Returns true if `configurationKey` has been explicitly set.
  public var hasConfigurationKey: Bool {return self._configurationKey != nil}
  /// Clears the value of `configurationKey`. Subsequent reads from it will return its default value.
  public mutating func clearConfigurationKey() {self._configurationKey = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _label: LLBLabel? = nil
  fileprivate var _configuredTargetValue: LLBConfiguredTargetValue? = nil
  fileprivate var _configurationKey: LLBConfigurationKey? = nil
}

/// The result of evaluating a configured target under a rule.
public struct LLBRuleEvaluationValue {
  // 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.

  /// The list of IDs that correspond to ActionKeys in the CAS.
  public var actionIds: [TSFCAS.LLBDataID] = []

  /// The providers returned by the evaluation of the rule
  public var providerMap: LLBProviderMap {
    get {return _providerMap ?? LLBProviderMap()}
    set {_providerMap = newValue}
  }
  /// Returns true if `providerMap` has been explicitly set.
  public var hasProviderMap: Bool {return self._providerMap != nil}
  /// Clears the value of `providerMap`. Subsequent reads from it will return its default value.
  public mutating func clearProviderMap() {self._providerMap = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _providerMap: LLBProviderMap? = nil
}

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

extension LLBRuleEvaluationKeyID: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "LLBRuleEvaluationKeyID"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "ruleEvaluationKeyID"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularMessageField(value: &self._ruleEvaluationKeyID)
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if let v = self._ruleEvaluationKeyID {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

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

extension LLBRuleEvaluationKey: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "LLBRuleEvaluationKey"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "label"),
    2: .same(proto: "configuredTargetValue"),
    3: .same(proto: "configurationKey"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularMessageField(value: &self._label)
      case 2: try decoder.decodeSingularMessageField(value: &self._configuredTargetValue)
      case 3: try decoder.decodeSingularMessageField(value: &self._configurationKey)
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if let v = self._label {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    }
    if let v = self._configuredTargetValue {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    }
    if let v = self._configurationKey {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: LLBRuleEvaluationKey, rhs: LLBRuleEvaluationKey) -> Bool {
    if lhs._label != rhs._label {return false}
    if lhs._configuredTargetValue != rhs._configuredTargetValue {return false}
    if lhs._configurationKey != rhs._configurationKey {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension LLBRuleEvaluationValue: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "LLBRuleEvaluationValue"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "actionIDs"),
    2: .same(proto: "providerMap"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeRepeatedMessageField(value: &self.actionIds)
      case 2: try decoder.decodeSingularMessageField(value: &self._providerMap)
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.actionIds.isEmpty {
      try visitor.visitRepeatedMessageField(value: self.actionIds, fieldNumber: 1)
    }
    if let v = self._providerMap {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: LLBRuleEvaluationValue, rhs: LLBRuleEvaluationValue) -> Bool {
    if lhs.actionIds != rhs.actionIds {return false}
    if lhs._providerMap != rhs._providerMap {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
