1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
pub use avro_schema;
impl From<avro_schema::error::Error> for crate::error::Error {
fn from(error: avro_schema::error::Error) -> Self {
Self::ExternalFormat(error.to_string())
}
}
pub mod read;
pub mod write;
macro_rules! avro_decode {
($reader:ident $($_await:tt)*) => {
{
let mut i = 0u64;
let mut buf = [0u8; 1];
let mut j = 0;
loop {
if j > 9 {
return Err(Error::ExternalFormat(
"zigzag decoding failed - corrupt avro file".to_string(),
));
}
$reader.read_exact(&mut buf[..])$($_await)*?;
i |= (u64::from(buf[0] & 0x7F)) << (j * 7);
if (buf[0] >> 7) == 0 {
break;
} else {
j += 1;
}
}
Ok(i)
}
}
}
pub(crate) use avro_decode;