Skip to main content

mlt_core/
lib.rs

1#![doc = include_str!("../README.md")]
2extern crate core;
3
4/// Validates stream metadata in constructors (crate-internal).
5macro_rules! validate_stream {
6    ($stream:expr, $expected:pat $(,)?) => {
7        if !matches!($stream.meta.stream_type, $expected) {
8            return Err($crate::MltError::UnexpectedStreamType2(
9                $stream.meta.stream_type,
10                stringify!($expected),
11                stringify!($stream),
12            ));
13        }
14    };
15}
16
17/// Invokes `$m!` with every data type a property or m-value column can hold.
18///
19/// This is the one place the set of kinds is written down. The value enums spell
20/// their variants out, so a kind missing here fails to compile rather than
21/// silently dropping out of the mappings.
22macro_rules! with_kinds {
23    ($m:ident) => {
24        $m! {
25            scalar { Bool, I8, U8, I32, U32, I64, U64, F32, F64 }
26            string { Str }
27        }
28    };
29}
30
31pub use fast_mvt;
32pub use geo_types;
33
34pub(crate) mod codecs;
35pub(crate) mod convert;
36pub(crate) mod decoder;
37pub mod dump;
38pub mod encoder;
39pub(crate) mod errors;
40pub(crate) mod layer_writer;
41pub(crate) mod tile;
42pub(crate) mod utils;
43
44pub use convert::{InferredKind, geojson, mvt};
45pub use decoder::{
46    ColNames, ColumnRef, Decoder, FeatureRef, GeometryType, GeometryValues, Layer, Layer01,
47    Layer01FeatureIter, LendingIterator, ParsedLayer, ParsedLayer01, Parser, PropName,
48    PropNamesIter, PropValueRef, Unknown,
49};
50// Crate-internal re-exports: allow internal modules to use `crate::Lazy` etc.
51// without exposing these implementation details to external users.
52pub(crate) use decoder::{
53    ColumnType, DictRange, DictionaryType, LengthType, OffsetType, RawPresence, RawSharedDict,
54    RawSharedDictItem, StreamType,
55};
56#[cfg(feature = "unstable-v2")]
57pub use decoder::{
58    Layer02, MValueColumn, MValueSpans, MValues, Nested, ParsedInterior, ParsedLayer02, ParsedLeaf,
59    ParsedList, ParsedMValue, ParsedMap, ParsedNested, ParsedNode, ParsedStruct, RawInterior,
60    RawLeaf, RawList, RawMValue, RawMap, RawNested, RawNode, RawStruct,
61};
62pub(crate) use errors::MltRefResult;
63pub use errors::{MltError, MltResult};
64pub use layer_writer::{FeatureWriter, LayerWriter};
65pub use tile::{
66    ColumnRole, Extent, PropKind, PropValue, PropertyKey, TileFeature, TileFeatureBuilder,
67    TileLayer, TileLayerBuilder,
68};
69#[cfg(feature = "unstable-v2")]
70pub use tile::{MValue, MValueKey, NestedKey, NestedKind, NestedValue, ZStep};
71pub(crate) use utils::analyze::{Analyze, StatType};
72pub(crate) use utils::lazy_state::{Decode, DecodeState, Lazy, LazyParsed, Parsed};
73
74/// Wire-level encoding metadata - for tile analysis and tooling.
75///
76/// These types describe the physical and logical encoding of streams inside an
77/// MLT tile. Normal tile consumers (parse -> iterate features) do not need this
78/// module; it is intended for tools that inspect or report encoding statistics.
79pub mod wire {
80    #[cfg(feature = "unstable-v2")]
81    pub use crate::decoder::stream::model::XyzLogical;
82    pub use crate::decoder::stream::model::{
83        Alp, BoolLogical, DictionaryType, FastPForKind, FloatLogical, IntEncoding, IntLogical,
84        LengthType, LogicalEncoding, LogicalTechnique, Morton, OffsetType, PhysicalEncoding,
85        RleLayout, RleMeta, StreamMeta, StreamType, ValueKind, VertexLogical,
86    };
87    pub use crate::decoder::{ColumnDecl, ColumnStorage, ColumnType, DictLayout, StringLayout};
88    #[cfg(feature = "unstable-v2")]
89    pub use crate::decoder::{GeoLayout, LayerLayout};
90    pub use crate::utils::analyze::{Analyze, StatType};
91}
92
93#[cfg(any(test, feature = "__private"))]
94pub use crate::utils::test_helpers;
95
96/// Private re-exports for benchmarks and integration tests. Not part of the public API.
97#[cfg(any(test, feature = "__private"))]
98#[doc(hidden)]
99pub mod __private {
100    pub use crate::codecs::*;
101    pub use crate::convert::*;
102    pub use crate::decoder::*;
103    pub use crate::errors::*;
104    pub use crate::test_helpers::*;
105    pub use crate::tile::*;
106    pub use crate::utils::analyze::*;
107    pub use crate::utils::lazy_state::*;
108    pub use crate::utils::*;
109}