final case class ProtoAny(typeUrl: String, value: ByteString)
The Scala shape of google.protobuf.Any: a type URL and the bytes it describes.
Kept as its own type rather than mapped to a stdlib one, because there is no stdlib type for "some message, identified at runtime". pack and unpackTo are where the type recovery happens, and they need the target's companion, which is exactly what a generated companion provides.
Parses the payload as A, failing when the type URL names something else.
Parses the payload as A, failing when the type URL names something else.
Checked rather than trusting: an Any arrives from the network, and parsing arbitrary bytes as the wrong message usually succeeds while producing nonsense.