kafrust-protocol
Kafka wire protocol primitives for kafrust.
kafrust-protocol is the runtime-free protocol crate used by the high-level
kafrust client. It owns Kafka request and response
encoding, response decoding, request/response headers, frame handling, and
focused wire-format tests.
This crate is not a Kafka client by itself. Applications should normally depend
on kafrust; this crate is public so protocol behavior can be inspected,
tested, and reused where low-level Kafka messages are needed.
Design Goals
- Keep Kafka API/version details explicit in type names.
- Keep wire-format code small and easy to audit.
- Avoid async runtime assumptions.
- Avoid
unsafe. - Add Kafka protocol surface only when encoding, decoding, and client behavior need it.
Implemented Areas
The 0.2.x protocol surface includes support used by the current high-level
client paths:
- primitive Kafka wire types
- nullable and compact strings/bytes/arrays
- tagged fields
- request and response headers
- frame encoding and decoding
ApiVersions v0Metadata v1FindCoordinator v1Produce v2MessageSet andProduce v3RecordBatch pathsFetch v2response decoding for MessageSet and RecordBatch recordsJoinGroup v2SyncGroup v2Heartbeat v2OffsetFetch v2OffsetCommit v2- classic consumer protocol subscription and assignment payloads
Encoding Example
use ApiVersionsRequestV0;
let request = ApiVersionsRequestV0 ;
let bytes = request.encode?;
assert!;
# Ok::
Decoding Example
use ApiVersionsResponseV0;
use Decoder;
let response_body = ;
let mut decoder = new;
let response = decode_body?;
assert_eq!;
assert_eq!;
# Ok::
Compatibility
Protocol types can exist before a high-level client path is verified against a real broker. kafrust compatibility claims are made from the high-level client crate and repository docs, not from the presence of protocol structs alone.
The current 0.2.x client compatibility claim is Apache Kafka 3.7.2,
single-node KRaft, over PLAINTEXT.
Current Limits
- This crate does not implement a broker.
- This crate does not perform network I/O.
- Protocol coverage is intentionally incomplete.
- Compression, transactions, idempotent producer protocol paths, and admin APIs are not complete yet.
- Public APIs are pre-
1.0and can change between minor versions.
Project Docs
- Repository: https://github.com/TaeeunKil/kafrust
- kafrust client crate: https://docs.rs/kafrust
- Roadmap: https://github.com/TaeeunKil/kafrust/blob/main/docs/roadmap.md
- Compatibility: https://github.com/TaeeunKil/kafrust/blob/main/docs/compatibility.md