rq
rq copied to clipboard
serde_avro - Access Header Details?
I have a rather simple example of pulling length prefixed binaries off the wire and parsing Avro:
let mut buf = Vec::with_capacity(4000);
let payload_size_in_bytes = match reader.read_u32::<BigEndian>() {
Ok(i) => i as usize,
Err(_) => return,
};
buf.resize(payload_size_in_bytes, 0);
if reader.read_exact(&mut buf).is_err() {
return;
}
match serde_avro::de::Deserializer::from_container(&buf[..]) {
Ok(avro_de) => {
}
Err(e) => {
trace!("Failed to deserialize container: {:?}", e.description());
return;
}
}
After constructing the deserializer successfully, is it possible for a user to get at the header details in anyway? I am interested in examining the "type" value indicated in the header.
I guess the parsed Header
struct could be preserved in the deserializer, would that work for your use-case? How would you like that to look?
Just posting so that folks know I haven't forgotten about this thread.
I hope to have something to propose by end of week.
Warning - I am only journeyman level when it comes to Rust.
I made an attempt here -https://github.com/dflemstr/rq/pull/171.
rq now uses avro-rs.