Schemas for "internal data"

17 views
Skip to first unread message

Matt Stern

unread,
Feb 16, 2021, 2:21:43 PMFeb 16
to Cap'n Proto
Hello!

Suppose team A produces data with the following schema:

struct Data {
  id @1 : Uint64;
  stuff @2: InternalData;
}

Now, team B consumes this data but doesn't want care about the "stuff" field, and team B does not want to include the schema files for InternalData. So in the consumer code, this schema is used instead:

struct Data {
  id @1: Uint64;
  stuff @2: Void; // Reserved for team A internal data.
}

Is this safe to do? If it's relevant, team A produces with C++ and team B consumes with Java.

(For the record, InternalData is not privacy sensitive or anything like that. I know that team B could peek into that struct even without the schema and reverse engineer).

Thanks!


Ian Denhardt

unread,
Feb 16, 2021, 2:32:16 PMFeb 16
to Cap'n Proto, Matt Stern
Quoting Matt Stern (2021-02-16 14:21:43)

> Is this safe to do? If it's relevant, team A produces with C++ and
> team B consumes with Java.

No; the representations of Void and InternalData are different (I assume
the latter is a struct), so you'll end up with two types that are
wire-incompatible.

Rather than using `Void`, you can use `AnyPointer`, in which case this
will work provided that `InternalData` is some pointer type (struct,
list, or interface).

Matt Stern

unread,
Feb 16, 2021, 2:50:57 PMFeb 16
to Ian Denhardt, Cap'n Proto
Thanks Ian.

Yes, InternalData is a struct. I'll give AnyPointer a look!
Reply all
Reply to author
Forward
0 new messages