v0.6 Rust 1.94.1+ MIT or Apache-2.0

Kafka wire formats, exactly.

An async Rust schema-registry client that speaks Confluent v0 and v1, Kafka-header schema IDs, and AWS Glue framing — verified byte-for-byte against the official serializers.

cargo add schemreg --features confluent,avro

Get started Read the wire-format guide

  • 3 / 3 Confluent placements verified against the official serializers
  • 0 unsafe blocks — the crate forbids them
  • 0 dependencies with no feature enabled
use schemreg::{
    CachedSchemaRegistry, ConfluentSchemaRegistry, EncodeTarget,
    SchemaResolution, WireFormatDecoder, AvroSchemaEncoder,
};

let registry = ConfluentSchemaRegistry::builder()
    .url("https://registry.example.com")
    .basic_auth("user", "password")
    .build()?;

// Bounded, coalescing, cancellation-safe.
let cached = Arc::new(CachedSchemaRegistry::new(registry));

// A producer that reads but never writes.
let encoder = AvroSchemaEncoder::builder()
    .registry(Arc::clone(&cached))
    .schema(ORDER_SCHEMA)
    .resolution(SchemaResolution::LookupOnly)
    .build()?;

let framed = encoder.encode(order, "orders", EncodeTarget::Value).await?;

// Consumer: one path for every framing the producer might have chosen.
let decoder = WireFormatDecoder::confluent(cached);
let message = decoder.decode(framed).await?;

Four framings, one decode path

A Kafka record names its schema in whichever way its producer chose. A consumer cannot know in advance, so decoding reports which one it found instead of committing to either.

Confluent v0

every Confluent Platform release

┌──────┬────────────────┬─────────┐
│ 0x00 │ schema ID (4B) │ payload │
└──────┴────────────────┴─────────┘

A registry-assigned integer. The same schema has a different ID in staging and in production, which is why replication has to rewrite every prefix.

Confluent v1

Confluent Platform 8+

┌──────┬─────────────────┬─────────┐
│ 0x01 │ schema GUID 16B │ payload │
└──────┴─────────────────┴─────────┘

A 128-bit fingerprint of the schema itself — its definition, references, metadata, and rules. The same everywhere, so records survive a cluster migration.

Kafka header

Confluent Platform 8+

__value_schema_id: 01 8f 14 e4 …
┌─────────────────────────────────┐
│ payload — no prefix at all      │
└─────────────────────────────────┘

The same prefix bytes, moved into a record header. The payload stays untouched, which is what makes a topic readable by tooling that knows nothing about the registry.

AWS Glue

18-byte header

┌──────┬──────┬───────────────┬─────────┐
│ 0x03 │ comp │ version UUID  │ payload │
└──────┴──────┴───────────────┴─────────┘

A header version byte, a compression indicator (`0x00` none, `0x05` ZLIB), and a 16-byte schema-version UUID in network order.

What you get

Zero-copy framing

Decoding slices the input rather than copying it: ~5 ns regardless of payload size, and flat across three orders of magnitude. Schemas are held behind `Arc<str>`, so a cache hit costs one atomic increment.

Verified against the reference

The v0 prefix, the v1 prefix and header mode — every Protobuf index shape — are pinned to bytes produced by the official `confluent-kafka-python` serializers on Confluent Platform 8, decoded and re-encoded byte-identically.

Header-first decoding

Every decoder reads a `__value_schema_id` / `__key_schema_id` header before the payload prefix, exactly like Confluent's deserializers. One `WireRecord` input; plain bytes still just work.

Post-quantum TLS, one provider

rustls on aws-lc-rs negotiates X25519MLKEM768 by default and trusts the OS store. A refused handshake is a typed, non-retryable error — not a retry storm.

Thundering-herd safe

N concurrent cold misses for one schema issue exactly one backend request. If the leading task is cancelled mid-flight, every waiter is woken with an error rather than left parked forever.

Nothing is invented

A field the registry did not report is `None`, never a plausible-looking default. Asking for GUID framing from a registry that has none is a clear error, not a fabricated identifier.

Descriptor-derived Protobuf paths

The message-index path comes from the compiled descriptor, so it cannot drift when someone reorders the `.proto`. Decoding can reject a payload whose message type is not the one you expected.

Feature-gated to the bone

The default feature set pulls in no transport stack at all. Enable `confluent`, `apicurio`, or `glue` for a client; `avro`, `json`, or `protobuf` for a codec. They compose in any combination.

Producers that never write to your registry

The default registers schemas — the same default the Confluent Java serdes ship, and the same one that quietly creates a production version the first time a developer's local schema drifts. One setting turns that into a startup failure instead.

  • AutoRegister — the default, matching auto.register.schemas=true. Needs Subject:Write.
  • LookupOnly — finds the registration or fails. Needs only Subject:Read.
  • UseLatestVersion — follows the subject's head, matching use.latest.version.
  • A drifted schema fails at the first encode with an error that is not retryable, so a retry loop stops instead of spinning.

Producer configuration guide

let encoder = AvroSchemaEncoder::builder()
    .registry(cached.clone())
    .schema(ORDER_SCHEMA)
    // Never creates a version in production.
    .resolution(SchemaResolution::LookupOnly)
    // 0x01 + a 16-byte GUID instead of 0x00 + 4 bytes.
    .framing(Framing::SchemaGuid)
    .build()?;

// Or move the identifier out of the payload entirely:
let record = encoder
    .encode_with_header(order, "orders", EncodeTarget::Value)
    .await?;

record.header_name;   // "__value_schema_id"
record.header_value;  // the prefix bytes
record.payload;       // serialised, and unframed

Registry support

RegistryFramingStatus
Confluent Schema Registry0x00 · 0x01 · headerNative client
Karapace0x00Confluent client
Redpanda Schema Registry0x00Confluent client
Apicurio Registry v30x00Native v3 client
Apicurio (ccompat)0x00Confluent client
AWS Glue Schema Registry0x03Native SDK client
Azure Event Hubs SRout-of-bandOut of scope
Buf Schema RegistrynoneNo runtime framing

Choosing a backend

Conformance is verified, not asserted

A golden vector written from the same misreading as the implementation agrees with it perfectly — and disagrees with every other Kafka client. So the Confluent framings are pinned against bytes produced by the official confluent-kafka-python serializers, decoded and re-encoded byte-identically, across every message-index shape.

Testing strategy Security posture

Crypto providers
1
`unsafe` blocks
0
Header decode
~5 ns
Cache hit
~23 ns

Start with the quick start

Encode, frame, and decode a record in about thirty lines — against a real registry or an in-memory stub.

Quick start API reference