New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 597115 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

Mojo: Expose generated serialization functions through public API

Project Member Reported by roc...@chromium.org, Mar 22 2016

Issue description

It is useful to be able to capture serialized structs without necessarily pushing them over a pipe right away.

For a concrete example, mash wm stores generic window properties as array<uint8>. Currently there are custom TypeConverters to go between real types and vector<uint8_t>, which is unfortunate. Ideally you could just say something like:

  mojom::RectPtr r = ...;
  mojo::Array<uint8_t> bytes;
  r->Serialize(&bytes);

and

  mojo::Array<uint8_t> bytes = ...;
  mojom::RectPtr r = mojom::Rect::Deserialize(bytes);

We could trivially generate implementations of Serialize and Deserialize for all mojom structs using the generated Serialize_ and Deserialize_ functions.

It would be worth considering this (though IMHO less obviously a good idea) for interface messages too since they are in practice just structs themselves.
 

Comment 1 by dcheng@chromium.org, Jun 16 2016

Cc: dcheng@chromium.org
How would Deserialize() signal failure?

Comment 2 by roc...@chromium.org, Jun 16 2016

The API should actually be

bool mojom::Rect::Deserialize(mojo::Array<uint8_t> bytes, mojom::RectPtr* out)

Comment 3 by roc...@chromium.org, Jun 16 2016

Also static. And really, it should just be 

static bool mojom::Rect::Deserialize(const uint8_t* bytes, mojom::RectPtr* out)

for maximum flexibility

Comment 4 by yzshen@chromium.org, Jun 16 2016

Owner: yzshen@chromium.org
Status: Started (was: Untriaged)

Comment 6 by yzshen@chromium.org, Aug 26 2016

Status: Fixed (was: Started)

Sign in to add a comment