AnyMessage

class AnyMessage(val typeUrl: String, val value: ByteString = ByteString.EMPTY) : Message<AnyMessage, Nothing>

Wire implementation of the google.protobuf.Any type. The Any type wraps an arbitrary protobuf message. Field of Any generated by Wire will be typed AnyMessage. typeUrl is used to identify the type of the message, defined as 'type.googleapis.com/full.type.name'. value is the serialized representation of the wrapped message. The pack and unpack methods are available to wrap and unwrap an Any message.

Example

val person: Person = anyMessage.unpack(Person.ADAPTER)
val anyMessage: AnyMessage = AnyMessage.ADAPTER.pack(person)

Constructors

Link copied to clipboard
constructor(typeUrl: String, value: ByteString = ByteString.EMPTY)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The ProtoAdapter for encoding and decoding messages of this type.

Link copied to clipboard
Link copied to clipboard
expect val unknownFields: ByteString

Returns a byte string containing the proto encoding of this message's unknown fields. Returns an empty byte string if this message has no unknown fields.

Link copied to clipboard
val value: ByteString

Functions

Link copied to clipboard
fun copy(typeUrl: String = this.typeUrl, value: ByteString = this.value): AnyMessage
Link copied to clipboard
expect fun encode(): ByteArray

Encode this message as a byte[].

expect fun encode(sink: BufferedSink)

Encode this message and write it to stream.

Link copied to clipboard
expect fun encodeByteString(): ByteString

Encode this message as a ByteString.

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
open override fun toString(): String
Link copied to clipboard
fun <T> unpack(adapter: ProtoAdapter<T>): T
Link copied to clipboard
fun <T> unpackOrNull(adapter: ProtoAdapter<T>): T?