Skip to content

Commit 6d7a407

Browse files
committed
feat(rust): squashed v2
1 parent 1829f11 commit 6d7a407

5 files changed

Lines changed: 2563 additions & 2 deletions

File tree

rust/mlt-core/src/decoder/layer.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::codecs::varint::parse_varint;
22
use crate::decoder::{Layer01, Unknown};
33
use crate::utils::{parse_u8, take};
4+
use crate::v2::decode_v2_layer;
45
use crate::{DecodeState, Decoder, Layer, MltError, MltRefResult, MltResult, ParsedLayer, Parser};
56

67
impl<'a, S: DecodeState> Layer<'a, S> {
@@ -9,7 +10,7 @@ impl<'a, S: DecodeState> Layer<'a, S> {
910
pub fn as_layer01(&self) -> Option<&Layer01<'a, S>> {
1011
match self {
1112
Self::Tag01(l) => Some(l),
12-
Self::Unknown(_) => None,
13+
_ => None,
1314
}
1415
}
1516

@@ -18,7 +19,7 @@ impl<'a, S: DecodeState> Layer<'a, S> {
1819
pub fn into_layer01(self) -> Option<Layer01<'a, S>> {
1920
match self {
2021
Self::Tag01(l) => Some(l),
21-
Self::Unknown(_) => None,
22+
_ => None,
2223
}
2324
}
2425
}
@@ -38,6 +39,7 @@ impl<'a> Layer<'a> {
3839

3940
let layer = match tag {
4041
1 => Layer::Tag01(Layer01::from_bytes(value, parser)?),
42+
2 => Layer::Tag02(decode_v2_layer(value)?),
4143
tag => Layer::Unknown(Unknown { tag, value }),
4244
};
4345

@@ -51,6 +53,7 @@ impl<'a> Layer<'a> {
5153
pub fn decode_all(self, dec: &mut Decoder) -> MltResult<ParsedLayer<'a>> {
5254
match self {
5355
Layer::Tag01(v) => Ok(Layer::Tag01(v.decode_all(dec)?)),
56+
Layer::Tag02(v) => Ok(Layer::Tag02(v)),
5457
Layer::Unknown(u) => Ok(Layer::Unknown(u)),
5558
}
5659
}

rust/mlt-core/src/decoder/model.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ impl From<Extent> for NonZeroU32 {
4141
pub enum Layer<'a, S: DecodeState = Lazy> {
4242
/// MVT-compatible layer (tag = 1)
4343
Tag01(Layer01<'a, S>),
44+
/// Experimental v2 layer (tag = 2), decoded eagerly to owned row-oriented form.
45+
///
46+
/// Unlike `Tag01`, this variant is always fully decoded when parsed: the
47+
/// `S` type parameter is ignored and the data is stored as a [`TileLayer01`].
48+
Tag02(TileLayer01),
4449
/// Unknown layer with tag, size, and value
4550
Unknown(Unknown<'a>),
4651
}
@@ -53,6 +58,7 @@ where
5358
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5459
match self {
5560
Self::Tag01(l) => f.debug_tuple("Tag01").field(l).finish(),
61+
Self::Tag02(t) => f.debug_tuple("Tag02").field(t).finish(),
5662
Self::Unknown(u) => f.debug_tuple("Unknown").field(u).finish(),
5763
}
5864
}

rust/mlt-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub(crate) mod decoder;
2323
pub mod encoder;
2424
pub(crate) mod errors;
2525
pub(crate) mod utils;
26+
pub mod v2;
2627

2728
pub use convert::{geojson, mvt};
2829
pub use decoder::{

rust/mlt-core/src/utils/test_helpers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub fn assert_empty<T>(result: MltRefResult<T>) -> T {
2727
pub fn into_layer01(layer: Layer) -> Layer01 {
2828
match layer {
2929
Layer::Tag01(v) => v,
30+
Layer::Tag02(_) => panic!("expected Tag01 layer, got Tag02"),
3031
Layer::Unknown(v) => panic!("expected Tag01 layer, got Tag{:02x}", v.tag),
3132
}
3233
}

0 commit comments

Comments
 (0)