All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.signal.svr2.proto.RestoreResponse.kt Maven / Gradle / Ivy

There is a newer version: 2.15.3_unofficial_107
Show newest version
// Code generated by Wire protocol buffer compiler, do not edit.
// Source: RestoreResponse in SVR2.proto
package org.signal.svr2.proto

import com.squareup.wire.EnumAdapter
import com.squareup.wire.FieldEncoding
import com.squareup.wire.Message
import com.squareup.wire.ProtoAdapter
import com.squareup.wire.ProtoReader
import com.squareup.wire.ProtoWriter
import com.squareup.wire.ReverseProtoWriter
import com.squareup.wire.Syntax
import com.squareup.wire.Syntax.PROTO_3
import com.squareup.wire.WireEnum
import com.squareup.wire.WireField
import kotlin.Any
import kotlin.Boolean
import kotlin.Int
import kotlin.Long
import kotlin.String
import kotlin.Unit
import kotlin.jvm.JvmField
import kotlin.jvm.JvmStatic
import okio.ByteString

public class RestoreResponse(
  @field:WireField(
    tag = 1,
    adapter = "org.signal.svr2.proto.RestoreResponse${'$'}Status#ADAPTER",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val status: Status = Status.UNSET,
  /**
   * between 16 and 48 bytes, if set
   */
  @field:WireField(
    tag = 2,
    adapter = "com.squareup.wire.ProtoAdapter#BYTES",
    label = WireField.Label.OMIT_IDENTITY,
    declaredName = "data",
  )
  @JvmField
  public val data_: ByteString = ByteString.EMPTY,
  /**
   * in range \[0,255\]
   */
  @field:WireField(
    tag = 3,
    adapter = "com.squareup.wire.ProtoAdapter#UINT32",
    label = WireField.Label.OMIT_IDENTITY,
  )
  @JvmField
  public val tries: Int = 0,
  unknownFields: ByteString = ByteString.EMPTY,
) : Message(ADAPTER, unknownFields) {
  public override fun newBuilder(): Builder {
    val builder = Builder()
    builder.status = status
    builder.data_ = data_
    builder.tries = tries
    builder.addUnknownFields(unknownFields)
    return builder
  }

  public override fun equals(other: Any?): Boolean {
    if (other === this) return true
    if (other !is RestoreResponse) return false
    if (unknownFields != other.unknownFields) return false
    if (status != other.status) return false
    if (data_ != other.data_) return false
    if (tries != other.tries) return false
    return true
  }

  public override fun hashCode(): Int {
    var result = super.hashCode
    if (result == 0) {
      result = unknownFields.hashCode()
      result = result * 37 + status.hashCode()
      result = result * 37 + data_.hashCode()
      result = result * 37 + tries.hashCode()
      super.hashCode = result
    }
    return result
  }

  public override fun toString(): String {
    val result = mutableListOf()
    result += """status=$status"""
    result += """data_=$data_"""
    result += """tries=$tries"""
    return result.joinToString(prefix = "RestoreResponse{", separator = ", ", postfix = "}")
  }

  public fun copy(
    status: Status = this.status,
    data_: ByteString = this.data_,
    tries: Int = this.tries,
    unknownFields: ByteString = this.unknownFields,
  ): RestoreResponse = RestoreResponse(status, data_, tries, unknownFields)

  public class Builder : Message.Builder() {
    @JvmField
    public var status: Status = Status.UNSET

    @JvmField
    public var data_: ByteString = ByteString.EMPTY

    @JvmField
    public var tries: Int = 0

    public fun status(status: Status): Builder {
      this.status = status
      return this
    }

    /**
     * between 16 and 48 bytes, if set
     */
    public fun data_(data_: ByteString): Builder {
      this.data_ = data_
      return this
    }

    /**
     * in range \[0,255\]
     */
    public fun tries(tries: Int): Builder {
      this.tries = tries
      return this
    }

    public override fun build(): RestoreResponse = RestoreResponse(
      status = status,
      data_ = data_,
      tries = tries,
      unknownFields = buildUnknownFields()
    )
  }

  public companion object {
    @JvmField
    public val ADAPTER: ProtoAdapter = object : ProtoAdapter(
      FieldEncoding.LENGTH_DELIMITED, 
      RestoreResponse::class, 
      "type.googleapis.com/RestoreResponse", 
      PROTO_3, 
      null, 
      "SVR2.proto"
    ) {
      public override fun encodedSize(`value`: RestoreResponse): Int {
        var size = value.unknownFields.size
        if (value.status != Status.UNSET) size += Status.ADAPTER.encodedSizeWithTag(1, value.status)
        if (value.data_ != ByteString.EMPTY) size += ProtoAdapter.BYTES.encodedSizeWithTag(2,
            value.data_)
        if (value.tries != 0) size += ProtoAdapter.UINT32.encodedSizeWithTag(3, value.tries)
        return size
      }

      public override fun encode(writer: ProtoWriter, `value`: RestoreResponse): Unit {
        if (value.status != Status.UNSET) Status.ADAPTER.encodeWithTag(writer, 1, value.status)
        if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2,
            value.data_)
        if (value.tries != 0) ProtoAdapter.UINT32.encodeWithTag(writer, 3, value.tries)
        writer.writeBytes(value.unknownFields)
      }

      public override fun encode(writer: ReverseProtoWriter, `value`: RestoreResponse): Unit {
        writer.writeBytes(value.unknownFields)
        if (value.tries != 0) ProtoAdapter.UINT32.encodeWithTag(writer, 3, value.tries)
        if (value.data_ != ByteString.EMPTY) ProtoAdapter.BYTES.encodeWithTag(writer, 2,
            value.data_)
        if (value.status != Status.UNSET) Status.ADAPTER.encodeWithTag(writer, 1, value.status)
      }

      public override fun decode(reader: ProtoReader): RestoreResponse {
        var status: Status = Status.UNSET
        var data_: ByteString = ByteString.EMPTY
        var tries: Int = 0
        val unknownFields = reader.forEachTag { tag ->
          when (tag) {
            1 -> try {
              status = Status.ADAPTER.decode(reader)
            } catch (e: ProtoAdapter.EnumConstantNotFoundException) {
              reader.addUnknownField(tag, FieldEncoding.VARINT, e.value.toLong())
            }
            2 -> data_ = ProtoAdapter.BYTES.decode(reader)
            3 -> tries = ProtoAdapter.UINT32.decode(reader)
            else -> reader.readUnknownField(tag)
          }
        }
        return RestoreResponse(
          status = status,
          data_ = data_,
          tries = tries,
          unknownFields = unknownFields
        )
      }

      public override fun redact(`value`: RestoreResponse): RestoreResponse = value.copy(
        unknownFields = ByteString.EMPTY
      )
    }

    private const val serialVersionUID: Long = 0L
  }

  public enum class Status(
    public override val `value`: Int,
  ) : WireEnum {
    /**
     * never returned
     */
    UNSET(0),
    /**
     * successfully restored, \[data\] will be set
     */
    OK(1),
    /**
     * db\[backup_id\] does not exist
     */
    MISSING(2),
    /**
     * pin did not match, tries were decremented
     */
    PIN_MISMATCH(3),
    /**
     * the request was not correctly specified, tries were not decremented
     */
    REQUEST_INVALID(4),
    ;

    public companion object {
      @JvmField
      public val ADAPTER: ProtoAdapter = object : EnumAdapter(
        Status::class, 
        PROTO_3, 
        Status.UNSET
      ) {
        public override fun fromValue(`value`: Int): Status? = Status.fromValue(value)
      }

      @JvmStatic
      public fun fromValue(`value`: Int): Status? = when (value) {
        0 -> UNSET
        1 -> OK
        2 -> MISSING
        3 -> PIN_MISMATCH
        4 -> REQUEST_INVALID
        else -> null
      }
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy