proto_unpack_any() decodes the message a google.protobuf.Any packs,
as proto_decode() decodes any message. The type is the part of
type_url after its last /, and must be in the pool.
proto_pack_any() is the inverse: it encodes a message with
proto_encode() and names its type, giving a value to set an Any
field to.
Usage
proto_unpack_any(x, pool, ...)
proto_pack_any(x, type, pool, prefix = "type.googleapis.com/", ...)Arguments
- x
For
proto_unpack_any(), anAnyasproto_decode()returns it: a list oftype_urlandvalue(the packed bytes). Forproto_pack_any(), the message, asproto_encode()takes it.- pool
A pool from
proto_pool()holding the packed type.- ...
Passed to
proto_decode()orproto_encode().- type
The message type's full name.
- prefix
The
type_urlbefore the type name, ending in/. Protobuf's JSON mapping and most runtimes expect the default.
Value
proto_unpack_any(): the packed message, as proto_decode()
returns it. proto_pack_any(): an Any, a list of type_url and
value.
Examples
pool <- proto_pool()
any <- proto_pack_any(42L, "google.protobuf.Int32Value", pool)
any$type_url
#> [1] "type.googleapis.com/google.protobuf.Int32Value"
proto_unpack_any(any, pool)
#> [1] 42