crabka-schema-serde
Client-agnostic, Confluent-compatible schema serializers/deserializers for Crabka.
It frames payloads with the Confluent wire format
(magic(0x00) | schema_id(4 BE) | body, plus the Protobuf message-index),
registers/resolves schemas against a Confluent-compatible Schema Registry, and
supports Avro, Protobuf, and JSON Schema via optional feature flags.
Features
| Feature | Enables | Schema source |
|---|---|---|
avro |
AvroSerde<T> |
apache-avro AvroSchema derive |
protobuf |
ProtobufSerde<T> |
prost + prost-reflect descriptor → .proto |
json |
JsonSerde<T> |
schemars JsonSchema derive |
= { = "0.3.2", = ["avro"] }
How it works
- A serde is constructed for a key/value role (
AvroSerde::<T>::value(&cache)/::key(&cache)) and derives its subject (<topic>-value/<topic>-keyviaTopicNameStrategy) from the topic passed at (de)serialize time — so one serde instance works across topics (like JVM Kafka'sserialize(topic, data)). register_subject(topic)interns the local schema into a shared [SchemaCache];SchemaCache::prewarm()resolves every interned subject's id once at startup — auto-registering (Confluent default) or looking up.serialize/deserializeare synchronous: they read ids from the cache. An unknown writer id on the deserialize path triggers a non-blocking background fetch and returns a retriable error until the cache fills.
Example (Avro)
use Arc;
use AvroSchema;
use ;
use ;
use ;
# async
For a Kafka Streams integration (the Serde<T> bridge + runnable per-format
pipelines), see crabka-client-streams with its
schema-serde feature.
License
Apache-2.0. See the repository LICENSE and NOTICE files.