[−]Derive Macro fluvio_dataplane_protocol::derive::Encode
#[derive(Encode)] { // Attributes available to this derive: #[varint] #[fluvio] }
Custom derive for encoding structure or enum to bytes using Kafka protocol format. This assumes all fields(or enum variants) implement kafka encode traits.
Examples
use fluvio_protocol::Encoder; use fluvio_protocol::derive::Encode; #[derive(Encode)] pub struct SimpleRecord { val: u8 } let data = vec![]; let record = SimpleRecord { val: 4}; recprd.encode(&mut data,0); assert_eq!(data[0],4);
Encode applys to either Struct of Enum.
Encode respects version attributes. See Decode derive.