Skip to content

Add truncating int primitive serializers #47

@schultzcole

Description

@schultzcole

It might sometimes be useful to have a serializer that serializes an int to fewer than 4 bytes.

As an example, StringSerializer takes in an int serializer to serialize the length of the string, but the length of the string is quite unlikely to actually reach int.MaxValue bytes. You could save bytes by using an int serializer that ignores the most significant bytes. For many cases, 1 or 2 bytes would be sufficient.

I think it would be implemented as a single class TruncatingIntSerializer, which can take a parameter of the number of bytes to use to serialize the value, and if an incoming value to serialize is larger than can be stored in that number of bytes, it throws an exception

Metadata

Metadata

Assignees

No one assigned

    Labels

    area - serializationChanges pertaining to serialization of datafeatureNew feature or request

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions