Skip to content

Commit 7355a4f

Browse files
committed
redid overview
1 parent 3d16338 commit 7355a4f

1 file changed

Lines changed: 33 additions & 16 deletions

File tree

README.md

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,51 @@
66

77
# KEncode
88

9-
**Compact, ASCII-safe encodings and ultra-small binary serialization for Kotlin, ideal for URLs, headers, file names, and other size-limited channels. Produces short and predictable payloads.**
9+
**Compact, ASCII-safe encodings and ultra-small binary serialization for Kotlin,
10+
ideal for URLs, headers, file names, and other size-limited channels. Produces
11+
short and predictable payloads.**
1012

1113
![Maven Central](https://img.shields.io/maven-central/v/com.eignex/kencode.svg?label=Maven%20Central)
1214
![Build](https://github.com/eignex/kencode/actions/workflows/build.yml/badge.svg)
1315
![codecov](https://codecov.io/gh/eignex/kencode/branch/main/graph/badge.svg)
1416
![License](https://img.shields.io/github/license/eignex/kencode)
1517

16-
> KEncode produces short, predictable text payloads that fit into environments with strict character or length limits such as URLs, file names, Kubernetes labels, and log keys.
18+
> KEncode produces short, predictable text payloads that fit into environments
19+
> with strict character or length limits such as URLs, file names, Kubernetes
20+
> labels, and log keys.
1721
18-
> It provides high-performance radix and base encoders, efficient integer coding, optional checksums, and a compact bit-packed serializer for flat data models.
22+
> It provides high-performance radix and base encoders, efficient integer
23+
> coding, optional checksums, and a compact bit-packed serializer for flat data
24+
> models.
1925
2026
---
2127

2228
## Overview
2329

24-
KEncode brings together several compact encoding tools: radix formats like Base36 and Base62, dense ASCII-safe formats such as Base64 and ASCII85-style Base85, varint and zig-zag integer coding, CRC-16 and CRC-32 checksums, and a minimal-allocation bit-packed serializer built on `kotlinx.serialization`.
30+
KEncode provides **three focused entry points**, all aimed at producing compact,
31+
ASCII-safe representations:
2532

26-
These features help you move structured data through **channels with tight ASCII or size constraints**, including:
33+
1. **ByteEncoding codecs**: `Base62` / `Base36` / `Base64` / `Base85`
34+
Low-level encoders/decoders for `ByteArray` values.
35+
Useful when you already have binary data and only need an ASCII-safe
36+
representation.
2737

28-
* URLs and query parameters
29-
* File names
30-
* Kubernetes pod names, labels, and annotations
31-
* HTTP headers and cookies
32-
* Message queue identifiers
33-
* Log keys and structured logging fields
38+
2. **Standalone BinaryFormat**: `PackedFormat`
39+
Produce compact binary payloads from Kotlin objects using
40+
`kotlinx.serialization` `BinaryFormat`.
41+
`PackedFormat` produces very small from flat structures using bitmasks,
42+
varints, but no object nesting. Use `kotlinx.serialization.ProtoBuf` instead
43+
when you need nested types, lists, or maps.
3444

35-
⚠️ Encrypt any payload that contains sensitive information.
45+
3. **Standalone StringFormat**: `EncodedFormat`
46+
Produce string payloads from Kotlin objects using `kotlinx.serialization`
47+
`StringFormat`.
48+
Encompasses a `BinaryFormat` + optional checksum + `ByteEncoding` text codec.
49+
Use when you want a single `encodeToString` / `decodeFromString` API that
50+
yields short, deterministic tokens.
3651

37-
The bit-packed serializer supports only flat structures. Use `ProtoBuf` from `kotlinx.serialization` when you need maps, nested types, or more complex layouts.
52+
KEncode focuses on minimal outputs; encrypt the payload first if it contains
53+
sensitive information.
3854

3955
---
4056

@@ -55,7 +71,7 @@ You also need to load the serialization plugin.
5571

5672
## Full serialization example
5773

58-
Minimal example using the default `EncodedFormat` (Base62 + PackedFormat):
74+
Minimal example using the default `EncodedFormat` (`Base62` + `PackedFormat`):
5975

6076
```kotlin
6177
@Serializable
@@ -147,7 +163,8 @@ println(encoded)
147163
val decoded = format.decodeFromString<ProtoBufRequired>(encoded)
148164
```
149165

150-
This example relies on kotlinx protobuf implementation, which you install:
166+
This example relies on kotlinx protobuf implementation, which you install:
167+
151168
```kotlin
152169
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:1.9.0")
153170
```
@@ -206,7 +223,7 @@ println(result)
206223

207224
## Checksums
208225

209-
You can add a CRC checksum at the string boundary. On decode, a mismatch
226+
You can add a CRC checksum to an `EncodedFormat`. On decode, a mismatch
210227
throws, so you get a simple integrity check on the serialized payload.
211228

212229
```kotlin

0 commit comments

Comments
 (0)