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

Serialization feature #158

Open
wants to merge 85 commits into
base: main
Choose a base branch
from

Conversation

DariusIMP
Copy link
Member

This PR is blocked by #157.

Description

This PR introduces the serialization and deserialization features that were recently introduced to all the Zenoh bindings.

It's inspired by the Kotlin serialization and deserialization, however, due to Java's limitations (specifically due to Java's type erasure), in this PR we introduce a depencency to the Guava library which provide reflection capabilities, allowing us to know during runtime the types into which the ZBytes must be serialized or deserialized.

The API looks like this:

        Map<String, Integer> input = Map.of("one", 1, "two", 2, "three", 3);
        var zbytes = zSerialize(input, new TypeToken<>() {});
        Map<String, Integer> output = zDeserialize(zbytes, new TypeToken<>() {});
        assert input.equals(output);

Java's type erasure forces us to require users to explicitely specify a new TypeToken<>() {} instance when calling zSerialize or zDeserialize. This creates a TypeToken instance storing the information regarding the input type at runtime.

The supported types for serialization/deserialization are:

  • Boolean
  • Byte
  • Byte Array
  • Short
  • Int
  • Long
  • Float
  • Double
  • String
  • List
  • Map

List and Map, which are parameterized types, support types nesting with any of the mentioned types. For instance:
Map<String, Map<String, Map<String, String>>> is a supported type.

…allback subclasses + tidying up documentation.
Copy link

PR missing one of the required labels: {'enhancement', 'internal', 'dependencies', 'new feature', 'documentation', 'breaking-change', 'bug'}

@DariusIMP DariusIMP requested a review from milyin December 13, 2024 19:21
@DariusIMP DariusIMP added enhancement New feature or request release Part of the next release labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request release Part of the next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant