kafka-serde

Rust's serde implementation for the Kafka protocol.

This allows you to serialize and deserialize kafka payloads. It can be used as a building block for a native-rust kafka client.

Usage

Serializing the kafka request header:

```rust use serde::Serialize; use std::io::{Write, Cursor};

[derive(Serialize, Debug)]

struct RequestHeader { apikey: i16, apiversion: i16, correlationid: i32, clientid: &'static str, }

let req = RequestHeader { apikey: 0, apiversion: 0, correlationid: 1, clientid: "" };

let mut x = Cursor::new(Vec::::new()); kafkaserde::towriter(x, &req).unwrap(); ```

Deserializing the kafka response header:

```rust use serde::Serialize;

[derive(Deserialize, Default, Debug, Clone)]

struct ResponseHeader { pub correlation: i32, }

let data : Vec = [0x0, 0x0, 0x0, 0x1]; let resp: ResponseHeader = kafkaserde::frombytes(&data).unwrap(); ```

Support

All Kafka protocol types are listed here