Skip to main content

mlt_core/frames/
model.rs

1use crate::frames::v01::Layer01;
2use crate::v01::{EncodedLayer01, StagedLayer01, StagedLayer01Encoder, Tag01Profile};
3
4/// A layer that can be one of the known types, or an unknown
5#[derive(Debug, PartialEq)]
6#[expect(clippy::large_enum_variant)]
7pub enum Layer<'a> {
8    /// MVT-compatible layer (tag = 1)
9    Tag01(Layer01<'a>),
10    /// Unknown layer with tag, size, and value
11    Unknown(Unknown<'a>),
12}
13
14/// Owned, pre-encoding variant of [`Layer`] (stage 2 of the encoding pipeline).
15#[derive(Debug, PartialEq, Clone)]
16#[expect(clippy::large_enum_variant)]
17#[cfg_attr(all(not(test), feature = "arbitrary"), derive(arbitrary::Arbitrary))]
18pub enum StagedLayer {
19    Tag01(StagedLayer01),
20    Unknown(EncodedUnknown),
21}
22
23/// Wire-ready variant of a layer (stage 3 of the encoding pipeline).
24#[derive(Debug, PartialEq, Clone)]
25#[expect(clippy::large_enum_variant)]
26pub enum EncodedLayer {
27    Tag01(EncodedLayer01),
28    Unknown(EncodedUnknown),
29}
30
31/// Unknown layer data, stored as encoded bytes
32#[derive(Debug, Clone, Default, PartialEq)]
33pub struct Unknown<'a> {
34    pub tag: u8,
35    pub value: &'a [u8],
36}
37
38/// Owned variant of [`Unknown`].
39#[derive(Debug, Clone, Default, PartialEq)]
40pub struct EncodedUnknown {
41    pub tag: u8,
42    pub value: Vec<u8>,
43}
44
45#[derive(Debug, Clone)]
46pub enum LayerEncoder {
47    Tag01(StagedLayer01Encoder),
48    Unknown,
49}
50
51/// Profile for a layer, built by running automatic optimisation over a
52/// representative sample of tiles and capturing the chosen encoders.
53///
54/// The `SortStrategy` stored inside the inner [`Tag01Profile`] is recorded
55/// so that profile-driven encoding can reproduce the same feature ordering on
56/// subsequent tiles.
57#[derive(Debug, Clone)]
58pub enum LayerProfile {
59    Tag01(Tag01Profile),
60    Unknown,
61}