Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.1.5 to 0.3.0 migration help #9

Open
djkoloski opened this issue May 8, 2023 · 1 comment
Open

0.1.5 to 0.3.0 migration help #9

djkoloski opened this issue May 8, 2023 · 1 comment

Comments

@djkoloski
Copy link

I'm trying to update my serialization benchmarks for alkahest from 0.1.5 to 0.3.0 but am struggling to figure out what the correct API migration path is:

  • It looks like there are both deserialize and deserialize_in_place methods available - which of those corresponds with a proper buffer-to-object deserialization? I think deserialize is the correct answer.
  • I'm looking for the zero-copy API that existed in 0.1 and can't seem to figure out where it is. I see Lazy which looks like the correct wrapper, but can't figure out how to make a Lazy from a byte buffer.

Thanks for all your hard work!

@zakarumych
Copy link
Owner

The API has been changed significantly.
And I hope it was simplified. At least that was one of the goals.

So 'deserialize' creates new value from raw bytes and 'deserialize_in_place' populates existing value.
This works similar to serde's methods of 'Deserialize' trait.

Alkahest no longer generates types to serialize and read data, instead user may implement 'Serialize' and 'Deserialize' traits or derive them.

'Lazy' type is closest to zero-copy deserialization in Alkahest now.
It is deserializable from formula in its type parameter, but deserialization is no-op as it just copies reference to bytes slice and size.
User may later deserialize from Lazy into any type that is deserializable from formula in type parameter.
If formula is a slice, there's additional option to iterate over serialized values deserializing them one by one.

To get 'Lazy' value, just derive 'Deserialize' for a type, using 'Lazy' for the field that you want to deserialize lazily. Make sure to use field type in formula type as type parameter to 'Lazy'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants