mp_bintools/docs/bipack.md

1.7 KiB

Module mp_bintools

Collection of binary tools

Most interesting:

  • Full set of CRC: [net.sergeych.bintools.CRC]
  • Binary bit-effective BiPack format serializer: [net.sergeych.bipack.BipackEncoder] and [net.sergeych.bipack.BipackDecoder]. Also typed key-value storage for it, see [net.sergeych.bipack.KVStorage] and its delegates and [net.sergeych.bipack.defaultNamedStorage].
  • Multiplatform synchronization tools, that works the same and properly on JS, native and JVM, see [net.sergeych.synctools]
  • many general-purpose utilities that simplify binary data processing, see package [net.sergeych.bintools] below.

Package net.sergeych.bipack

Bipack is a common kotlinx serializer that works pretty much like any other kotlinx.serialization format. You just mark your class as @Serializable and it does the rest.

  • [BipackEncoder] to serializes anything to bipack format.
  • [BipackDecoder] deserializes from bipack back.

There are also special annotation to fine tune the format: [Extendable], [Framed], [CrcProtected] for classes and [Unsigned] for integer data fields.

Package net.sergeych.bintools

General-purpose binary tools: encoding to bytes, hex, binary dumps. variable length integer, ect. Most of it is used internally by bipack serializers, see [net.sergeych.bipack] for details.

In particular, see [Varint] and [Smartint] variable-length compact integer codecs and also [DataSource] and [DataSink] multiplatform synchronous read/write interfaces.

Package net.sergeych.synctools

To write a code that compiles and runs, and most likely works on the JS, native, and JVM, we need some portable/compatible synchronization primitives. This package is a collection of such.