RuntimeMessageAdapter

Constructors

Link copied to clipboard
constructor(binding: MessageBinding<M, B>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Field bindings by index. The indexes are consistent across all related fields including jsonNames, jsonAlternateNames, and the result of jsonAdapters.

Link copied to clipboard
Link copied to clipboard
expect val identity: M?

A special value that is used when a field is absent from an encoded proto3 message. When encoding a proto3 message, fields that hold this value will be omitted.

Link copied to clipboard

When reading JSON these are alternate names for each field. If null the field has no alternate name.

Link copied to clipboard

When writing each field as JSON this is the name to use.

Link copied to clipboard
Link copied to clipboard
expect val sourceFile: String?

Path to the file containing the protobuf definition of this type.

Link copied to clipboard
expect val syntax: Syntax

Identifies the syntax in which type is defined in the proto schema. This string contains either "proto2" or "proto3".

Link copied to clipboard
expect val type: KClass<*>?
Link copied to clipboard
expect val typeUrl: String?

Identifies this type for inclusion in a google.protobuf.Any. This is a string like "type.googleapis.com/packagename.messagename" or null if this type is either not a message (such as scalars and enums), or was code-generated before Wire 3.2 which introduced support for type URLS.

Functions

Link copied to clipboard
expect fun asPacked(): ProtoAdapter<List<M>>

Returns an adapter for E but as a packed, repeated value.

Link copied to clipboard
expect fun asRepeated(): ProtoAdapter<List<M>>

Returns an adapter for E but as a repeated value.

Link copied to clipboard
expect fun decode(bytes: ByteArray): M
expect fun decode(bytes: ByteString): M

Read an encoded message from bytes.

expect fun decode(source: BufferedSource): M

Read an encoded message from source.

open override fun decode(reader: ProtoReader): M

Read a non-null value from reader.

Link copied to clipboard

Read an encoded message from data.

Link copied to clipboard
expect fun encode(value: M): ByteArray

Encode value as a byte[].

expect fun encode(sink: BufferedSink, value: M)

Encode value and write it to stream.

open override fun encode(writer: ProtoWriter, value: M)
open override fun encode(writer: ReverseProtoWriter, value: M)

Write non-null value to writer.

Link copied to clipboard
expect fun encodeByteString(value: M): ByteString

Encode value as a ByteString.

Link copied to clipboard
open override fun encodedSize(value: M): Int

The size of the non-null data value. This does not include the size required for a length-delimited prefix (should the type require one).

Link copied to clipboard
expect open fun encodedSizeWithTag(tag: Int, value: M?): Int

The size of tag and value in the wire format. This size includes the tag, type, length-delimited prefix (should the type require one), and value. Returns 0 if value is null.

Link copied to clipboard
expect open fun encodeWithTag(writer: ProtoWriter, tag: Int, value: M?)
expect open fun encodeWithTag(writer: ReverseProtoWriter, tag: Int, value: M?)

Write tag and value to writer. If value is null this does nothing.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun newBuilder(): B
Link copied to clipboard
open override fun redact(value: M): M

Returns the redacted form of value.

Link copied to clipboard
open override fun toString(value: M): String

Returns a human-readable version of the given value.

Link copied to clipboard
expect fun tryDecode(reader: ProtoReader, destination: MutableList<M>)

Reads a value and appends it to destination if this has data available. Otherwise, it will only clear the reader state.

Link copied to clipboard
fun <A> writeAllFields(message: M?, jsonAdapters: List<A>, redactedFieldsAdapter: A?, encodeValue: (String, Any?, A) -> Unit)

Walk the fields of message and invoke encodeValue on each that should be written as JSON. This omits fields that have the identity value when that is required.