gistools/readers/osm/
blob.rs1use crate::util::{CompressionFormat::DeflateRaw, decompress_data};
2use alloc::{string::String, vec::Vec};
3use pbf::{ProtoRead, Protobuf};
4
5pub const OSM_MAX_HEADER_SIZE: usize = 64 * 1024;
7pub const OSM_MAX_BLOB_SIZE: usize = 32 * 1024 * 1024;
9
10#[derive(Debug, Default)]
15pub struct BlobHeader {
16 pub _type: String,
18 pub indexdata: Vec<u8>,
20 pub datasize: u64,
22}
23impl ProtoRead for BlobHeader {
25 fn read(&mut self, tag: u64, pb: &mut Protobuf) {
26 match tag {
27 1 => self._type = pb.read_string(),
28 2 => self.indexdata = pb.read_bytes(),
29 3 => self.datasize = pb.read_varint(),
30 _ => panic!("unknown tag {}", tag),
31 }
32 }
33}
34
35#[derive(Debug, Default)]
38pub struct Blob {
39 pub raw_size: i32,
41 pub data: Vec<u8>,
43}
44impl ProtoRead for Blob {
46 fn read(&mut self, tag: u64, pb: &mut Protobuf) {
47 match tag {
48 1 => self.data = pb.read_bytes(),
49 2 => self.raw_size = pb.read_varint(),
50 3 => self.data = decompress_data(&pb.read_bytes(), DeflateRaw).unwrap(),
52 4..=6 => panic!("LZMA, bzip2 and LZ4 not supported"),
53 _ => panic!("unknown tag {}", tag),
54 }
55 }
56}