Skip to content

Commit e555f82

Browse files
committed
clarified some details in readme
1 parent 7cc7234 commit e555f82

1 file changed

Lines changed: 21 additions & 24 deletions

File tree

README.md

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,33 @@
11
<p align="center">
2-
<a href="https://www.eignex.com/">
2+
<a href="https://eignex.com/">
33
<img src="https://raw.githubusercontent.com/Eignex/.github/refs/heads/main/profile/banner.svg" style="max-width: 100%; width: 22em" />
44
</a>
55
</p>
66

77
# KEncode
88

9-
**High-efficiency binary/text codecs with compact bit-packed serialization for
10-
Kotlin.**
11-
129
[![Maven Central](https://img.shields.io/maven-central/v/com.eignex/kencode.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/com.eignex/kencode/1.0.0)
1310
[![Build](https://github.com/eignex/kencode/actions/workflows/build.yml/badge.svg)](https://github.com/eignex/kencode/actions/workflows/build.yml)
1411
[![codecov](https://codecov.io/gh/eignex/kencode/branch/main/graph/badge.svg)](https://codecov.io/gh/eignex/kencode)
1512
[![License](https://img.shields.io/github/license/eignex/kencode)](https://github.com/eignex/kencode/blob/main/LICENSE)
1613

17-
> KEncode produces short, predictable text payloads for environments with strict
18-
> character or length limits such as URLs, file names, Kubernetes labels, and log
19-
> keys.
14+
KEncode produces short, predictable text payloads for environments with strict
15+
character or length limits such as URLs, file names, Kubernetes labels, and log
16+
keys.
2017

2118
---
2219

2320
## Overview
2421

2522
KEncode provides three entry points for compact, ASCII-safe representations:
2623

27-
1. ByteEncoding codecs: Base62, Base36, Base64, and Base85 low-level encoders
24+
1. **ByteEncoding** codecs: Base62, Base36, Base64, and Base85 encoders
2825
for raw binary data.
29-
2. PackedFormat: A binary serializer optimized for Kotlin that supports nested
30-
objects, lists, and maps. It uses bitsets for booleans and nullability to
31-
minimize overhead.
32-
3. EncodedFormat: A wrapper that combines a binary format, an optional checksum,
33-
and a text codec to produce deterministic string identifiers.
26+
2. **PackedFormat**: A binary serializer optimized for Kotlin that supports
27+
nested objects, lists, and maps. It uses bitsets for booleans and nullability
28+
to minimize overhead.
29+
3. **EncodedFormat**: A wrapper that combines a binary format, an optional
30+
checksum, and a text codec to produce deterministic string identifiers.
3431

3532
### Installation
3633

@@ -72,6 +69,7 @@ val payload = Payload(
7269
)
7370

7471
val encoded = EncodedFormat.encodeToString(payload)
72+
// > 0fiXYI (that's it, this specific payload fits in 4 raw bytes)
7573
val decoded = EncodedFormat.decodeFromString<Payload>(encoded)
7674
```
7775

@@ -83,8 +81,8 @@ PackedFormat is a BinaryFormat designed to produce the smallest feasible
8381
payloads for Kotlin classes by moving structural metadata into a header.
8482

8583
* Bit-Packing: Booleans and nullability markers are stored in a single
86-
bit-header (1 bit per field).
87-
* VarInts: Integer fields can be optimized using @VarUInt or @VarInt (ZigZag)
84+
bit-header (about 1 bit per field).
85+
* VarInts: Int/Long fields can be optimized using @VarUInt or @VarInt (ZigZag)
8886
annotations.
8987
* Full Graph Support: Handles nested objects, lists, maps, and polymorphism
9088
recursively.
@@ -93,15 +91,14 @@ payloads for Kotlin classes by moving structural metadata into a header.
9391

9492
For a standard class, the encoding follows this structure:
9593

96-
1. Bitmask Header: A varlong containing bits for all booleans and nullable
97-
indicators. A class with 10 booleans and 5 nullable fields uses ~2 bytes of
98-
overhead.
94+
1. Bitmask Header: A variable length bitset containing bits for all booleans and
95+
nullable indicators. A class with 10 booleans and 5 nullable fields uses 2
96+
bytes for the header (the boolean variables are inlined to the header).
9997
2. Payload bytes: Fields are encoded in declaration order.
100-
101-
* Primitives: Encoded densely (VarInt for Int/Long, fixed for others).
102-
* Strings: [varint length][UTF-8 bytes].
103-
* Nested Objects: Recursively encodes the child object with its own header.
104-
* Collections: [varint size][items...]. Nulls in lists use inline markers.
98+
* Primitives: Encoded densely (VarInt for Int/Long, fixed for others).
99+
* Strings: [varint length][UTF-8 bytes].
100+
* Nested Objects: Recursively encodes the child object with its own header.
101+
* Collections: [varint size][items...]. Nulls in lists use inline markers.
105102

106103
---
107104

@@ -157,4 +154,4 @@ val encrypted = cipher.doFinal(binary)
157154
val token = Base62.encode(encrypted)
158155
```
159156
See [Examples](https://github.com/Eignex/kencode/blob/main/src/test/kotlin/com/eignex/kencode/Examples.kt)
160-
for a Bouncycastle demo.
157+
for a BouncyCastle demo.

0 commit comments

Comments
 (0)