Skip to content

Conversation

@DariusIMP
Copy link
Member

@DariusIMP DariusIMP commented Dec 13, 2024

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:

        List<Integer> input = List.of(1, 2, 3, 4, 5);
        var serializer = new ZSerializer<List<Integer>>() {};
        var zbytes = serializer.serialize(input);

        var deserializer = new ZDeserializer<List<Integer>>() {};
        List<Integer> output = deserializer.deserialize(zbytes);
        assert input.equals(output);

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.
@github-actions
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
@milyin milyin merged commit 9f9ddae into eclipse-zenoh:main Dec 26, 2024
8 checks passed
@DariusIMP DariusIMP deleted the serialization branch December 27, 2024 18:37
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.

2 participants