// DO NOT EDIT.
// swift-format-ignore-file
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: SystemMessages.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 Distributed Actors open source project
//
// Copyright (c) 2018-2019 Apple Inc. and the Swift Distributed Actors project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.md for the list of Swift Distributed Actors project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

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
}

public struct _ProtoSystemMessage {
  // 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.

  public var payload: _ProtoSystemMessage.OneOf_Payload? = nil

  public var watch: _ProtoSystemMessage_Watch {
    get {
      if case .watch(let v)? = payload {return v}
      return _ProtoSystemMessage_Watch()
    }
    set {payload = .watch(newValue)}
  }

  public var unwatch: _ProtoSystemMessage_Unwatch {
    get {
      if case .unwatch(let v)? = payload {return v}
      return _ProtoSystemMessage_Unwatch()
    }
    set {payload = .unwatch(newValue)}
  }

  public var terminated: _ProtoSystemMessage_Terminated {
    get {
      if case .terminated(let v)? = payload {return v}
      return _ProtoSystemMessage_Terminated()
    }
    set {payload = .terminated(newValue)}
  }

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public enum OneOf_Payload: Equatable {
    case watch(_ProtoSystemMessage_Watch)
    case unwatch(_ProtoSystemMessage_Unwatch)
    case terminated(_ProtoSystemMessage_Terminated)

  #if !swift(>=4.1)
    public static func ==(lhs: _ProtoSystemMessage.OneOf_Payload, rhs: _ProtoSystemMessage.OneOf_Payload) -> Bool {
      // 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 (lhs, rhs) {
      case (.watch, .watch): return {
        guard case .watch(let l) = lhs, case .watch(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.unwatch, .unwatch): return {
        guard case .unwatch(let l) = lhs, case .unwatch(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      case (.terminated, .terminated): return {
        guard case .terminated(let l) = lhs, case .terminated(let r) = rhs else { preconditionFailure() }
        return l == r
      }()
      default: return false
      }
    }
  #endif
  }

  public init() {}
}

public struct _ProtoSystemMessage_Watch {
  // 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.

  public var watchee: _ProtoActorAddress {
    get {return _watchee ?? _ProtoActorAddress()}
    set {_watchee = newValue}
  }
  /// Returns true if `watchee` has been explicitly set.
  public var hasWatchee: Bool {return self._watchee != nil}
  /// Clears the value of `watchee`. Subsequent reads from it will return its default value.
  public mutating func clearWatchee() {self._watchee = nil}

  public var watcher: _ProtoActorAddress {
    get {return _watcher ?? _ProtoActorAddress()}
    set {_watcher = newValue}
  }
  /// Returns true if `watcher` has been explicitly set.
  public var hasWatcher: Bool {return self._watcher != nil}
  /// Clears the value of `watcher`. Subsequent reads from it will return its default value.
  public mutating func clearWatcher() {self._watcher = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _watchee: _ProtoActorAddress? = nil
  fileprivate var _watcher: _ProtoActorAddress? = nil
}

public struct _ProtoSystemMessage_Unwatch {
  // 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.

  public var watchee: _ProtoActorAddress {
    get {return _watchee ?? _ProtoActorAddress()}
    set {_watchee = newValue}
  }
  /// Returns true if `watchee` has been explicitly set.
  public var hasWatchee: Bool {return self._watchee != nil}
  /// Clears the value of `watchee`. Subsequent reads from it will return its default value.
  public mutating func clearWatchee() {self._watchee = nil}

  public var watcher: _ProtoActorAddress {
    get {return _watcher ?? _ProtoActorAddress()}
    set {_watcher = newValue}
  }
  /// Returns true if `watcher` has been explicitly set.
  public var hasWatcher: Bool {return self._watcher != nil}
  /// Clears the value of `watcher`. Subsequent reads from it will return its default value.
  public mutating func clearWatcher() {self._watcher = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _watchee: _ProtoActorAddress? = nil
  fileprivate var _watcher: _ProtoActorAddress? = nil
}

public struct _ProtoSystemMessage_Terminated {
  // 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.

  public var ref: _ProtoActorAddress {
    get {return _ref ?? _ProtoActorAddress()}
    set {_ref = newValue}
  }
  /// Returns true if `ref` has been explicitly set.
  public var hasRef: Bool {return self._ref != nil}
  /// Clears the value of `ref`. Subsequent reads from it will return its default value.
  public mutating func clearRef() {self._ref = nil}

  public var existenceConfirmed: Bool = false

  public var addressTerminated: Bool = false

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _ref: _ProtoActorAddress? = nil
}

public struct _ProtoSystemMessageACK {
  // 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.

  public var sequenceNr: UInt64 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

public struct _ProtoSystemMessageNACK {
  // 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.

  /// repeated missingSequenceNrs
  public var sequenceNr: UInt64 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

public struct _ProtoSystemMessageEnvelope {
  // 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.

  public var sequenceNr: UInt64 = 0

  public var message: _ProtoSystemMessage {
    get {return _message ?? _ProtoSystemMessage()}
    set {_message = newValue}
  }
  /// Returns true if `message` has been explicitly set.
  public var hasMessage: Bool {return self._message != nil}
  /// Clears the value of `message`. Subsequent reads from it will return its default value.
  public mutating func clearMessage() {self._message = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _message: _ProtoSystemMessage? = nil
}

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

extension _ProtoSystemMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "SystemMessage"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "watch"),
    2: .same(proto: "unwatch"),
    3: .same(proto: "terminated"),
  ]

  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 {
        var v: _ProtoSystemMessage_Watch?
        var hadOneofValue = false
        if let current = self.payload {
          hadOneofValue = true
          if case .watch(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {
          if hadOneofValue {try decoder.handleConflictingOneOf()}
          self.payload = .watch(v)
        }
      }()
      case 2: try {
        var v: _ProtoSystemMessage_Unwatch?
        var hadOneofValue = false
        if let current = self.payload {
          hadOneofValue = true
          if case .unwatch(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {
          if hadOneofValue {try decoder.handleConflictingOneOf()}
          self.payload = .unwatch(v)
        }
      }()
      case 3: try {
        var v: _ProtoSystemMessage_Terminated?
        var hadOneofValue = false
        if let current = self.payload {
          hadOneofValue = true
          if case .terminated(let m) = current {v = m}
        }
        try decoder.decodeSingularMessageField(value: &v)
        if let v = v {
          if hadOneofValue {try decoder.handleConflictingOneOf()}
          self.payload = .terminated(v)
        }
      }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    switch self.payload {
    case .watch?: try {
      guard case .watch(let v)? = self.payload else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    }()
    case .unwatch?: try {
      guard case .unwatch(let v)? = self.payload else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    }()
    case .terminated?: try {
      guard case .terminated(let v)? = self.payload else { preconditionFailure() }
      try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
    }()
    case nil: break
    }
    try unknownFields.traverse(visitor: &visitor)
  }

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

extension _ProtoSystemMessage_Watch: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "SystemMessage_Watch"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "watchee"),
    2: .same(proto: "watcher"),
  ]

  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.decodeSingularMessageField(value: &self._watchee) }()
      case 2: try { try decoder.decodeSingularMessageField(value: &self._watcher) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    try { if let v = self._watchee {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    } }()
    try { if let v = self._watcher {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    } }()
    try unknownFields.traverse(visitor: &visitor)
  }

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

extension _ProtoSystemMessage_Unwatch: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "SystemMessage_Unwatch"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "watchee"),
    2: .same(proto: "watcher"),
  ]

  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.decodeSingularMessageField(value: &self._watchee) }()
      case 2: try { try decoder.decodeSingularMessageField(value: &self._watcher) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    try { if let v = self._watchee {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    } }()
    try { if let v = self._watcher {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    } }()
    try unknownFields.traverse(visitor: &visitor)
  }

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

extension _ProtoSystemMessage_Terminated: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "SystemMessage_Terminated"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "ref"),
    2: .same(proto: "existenceConfirmed"),
    3: .same(proto: "addressTerminated"),
  ]

  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.decodeSingularMessageField(value: &self._ref) }()
      case 2: try { try decoder.decodeSingularBoolField(value: &self.existenceConfirmed) }()
      case 3: try { try decoder.decodeSingularBoolField(value: &self.addressTerminated) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    try { if let v = self._ref {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
    } }()
    if self.existenceConfirmed != false {
      try visitor.visitSingularBoolField(value: self.existenceConfirmed, fieldNumber: 2)
    }
    if self.addressTerminated != false {
      try visitor.visitSingularBoolField(value: self.addressTerminated, fieldNumber: 3)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: _ProtoSystemMessage_Terminated, rhs: _ProtoSystemMessage_Terminated) -> Bool {
    if lhs._ref != rhs._ref {return false}
    if lhs.existenceConfirmed != rhs.existenceConfirmed {return false}
    if lhs.addressTerminated != rhs.addressTerminated {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

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

  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.decodeSingularUInt64Field(value: &self.sequenceNr) }()
      default: break
      }
    }
  }

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

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

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

  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.decodeSingularUInt64Field(value: &self.sequenceNr) }()
      default: break
      }
    }
  }

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

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

extension _ProtoSystemMessageEnvelope: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = "SystemMessageEnvelope"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "sequenceNr"),
    2: .same(proto: "message"),
  ]

  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.decodeSingularUInt64Field(value: &self.sequenceNr) }()
      case 2: try { try decoder.decodeSingularMessageField(value: &self._message) }()
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    // The use of inline closures is to circumvent an issue where the compiler
    // allocates stack space for every if/case branch local when no optimizations
    // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
    // https://github.com/apple/swift-protobuf/issues/1182
    if self.sequenceNr != 0 {
      try visitor.visitSingularUInt64Field(value: self.sequenceNr, fieldNumber: 1)
    }
    try { if let v = self._message {
      try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
    } }()
    try unknownFields.traverse(visitor: &visitor)
  }

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