You can simply prepending the serialized tag and length before the
serialized data of content.
Say, content is 0x0A0B0C0D, the you just prepend 0x12 (number is 2, type is
length-delimited) and 0x04 (content is 4 bytes long).
So 0x12040A0B0C0D will be the data for wrapper.

On Fri, Jan 26, 2018 at 1:50 PM Mike Trienis <[email protected]>
wrote:

> I'm trying to understand if it's possible to take a serialized protobuf
> that makes up part of another protobuf and merge them together without
> having to deserialize the first protobuf.
>
> For example, given a protobuf wrapper:
>
> syntax = "proto2";
>
> import "content.proto";
>
> message WrapperContent {
>  // The schema version of the message envelope. For example,
> messageSchemaVersion = '1.1.1'
>  required string metatData = 1;
>  // The payload as well as any common fields across all events
>  required Content content = 2;
>
> }
>
>
> And then imagine we get a serialized version of *content* below (i.e.
> *content* is coming that is coming from a remote client):
>
> syntax = "proto2";
>
> message Content {
>  // The schema version of the message envelope. For example,
> messageSchemaVersion = '1.1.1'
>  required string name = 1;
>  // The payload as well as any common fields across all events
>  required bytes payload = 2;
>
> }
>
> Do you know if any way I can inject the serialized *Content *into the
> *WrapperContent *without first having to deserialize *Content. *
>
> The reason I'm trying to inject Content without deserializing it, is to
> try and save on the overhead of deserializing the message.
>
> Thanks, Mike.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to