mln_style/lib.rs
1//! The map style: [`Style`], the style JSON parser, layers and sources, the
2//! property system (`property`), the expression language (`expression`), what
3//! expressions read of a feature (`feature`), the spec's value types (`types`)
4//! and the conversions from JSON-like values to style types (`conversion`).
5//!
6//! It also holds the vocabulary that the style shares with the engine:
7//! errors, colors, padding, sizes, ranges, interpolation and easing
8//! (`unitbezier`), images' pixels (`bitmap`), coordinates (`geo`), tilesets,
9//! feature types (`geometry`), canonical tile ids (`tile_id`), the spec's
10//! constants, math, number formatting (`string`), hash maps, clocks
11//! (`time`), the Unicode script checks (`i18n`) and the projection's
12//! subdivision granularity.
13//!
14//! A style parses against a [`StyleRegistry`]: the expression functions,
15//! layer types and source types its JSON, property values and filters may
16//! name, the extension members (`member`) that give the style's and its
17//! layers' `<namespace>:<name>` members a type, and the projections (`crs`)
18//! its `projection.type` may name.
19//!
20//! Versions:
21//! - A [`Style`] is a value: a version of a map's style. Its parts sit
22//! behind `Arc`s, so versions share what they don't change, and a part
23//! whose `Arc` is the same pointer in two versions is the same part.
24//! - [`Style::apply`] makes an [`Edit`], the only way to change a style; the
25//! JSON entry points (`add_layer_json`, `set_layer_property_json`, ...)
26//! parse and then apply one.
27//! - [`Style::is_same_version`] says in O(1) whether two versions are the
28//! same, and [`diff::StyleDiff::between`] what a renderer has to redo for
29//! each layer, source and image to go from one version to another.
30//! - Loading isn't here: the map's loader fetches documents, sprites and
31//! source descriptions, and [`Style::from_json`] parses a document. A
32//! style holds its sources as values ([`SourceList`]), and what their
33//! loads find, of a type that the source type's engine half names,
34//! arrives as edits.
35//!
36//! Layers:
37//! - `layer::Layer` is a layer of any type. Its style data is an
38//! `Arc<dyn layer::ErasedLayerStyle>`, a `layer::LayerStyle<T>`
39//! of its type `T`; `layer::LayerBase` holds the members every layer
40//! type has.
41//! - Each layer type is a marker type that implements
42//! `layer::StyleLayerType`, such as `layers::Background`, with
43//! property sets such as
44//! `layers::BackgroundPaintProperties::{Transitionable, Unevaluated, PossiblyEvaluated, Evaluated}`.
45//! - Each layer type, the light and the sky have a property table, which
46//! `property::table` reads to get, set and serialize properties by name.
47//! `layers/<type>_layer_properties.rs`, `light_properties.rs` and
48//! `sky_properties.rs` are generated by //tools/style-codegen from the style
49//! spec.
50
51#![warn(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
52#![cfg_attr(not(test), warn(clippy::unreachable, clippy::print_stdout, clippy::print_stderr))]
53
54#[cfg(target_os = "android")]
55pub mod android;
56pub mod bitmap;
57pub mod collections;
58pub mod color;
59pub mod constants;
60pub mod conversion;
61pub mod crs;
62pub mod error;
63pub mod expression;
64pub mod feature;
65pub mod filter;
66pub mod font_face;
67pub mod geo;
68pub mod geometry;
69pub mod hash;
70pub mod i18n;
71pub mod image;
72pub mod interpolate;
73pub mod layer;
74pub mod layers;
75pub mod light;
76#[rustfmt::skip]
77mod light_properties;
78pub mod math;
79pub mod member;
80pub mod padding;
81pub mod projection;
82pub mod property;
83pub mod range;
84pub mod registry;
85pub mod size;
86pub mod sky;
87#[rustfmt::skip]
88mod sky_properties;
89pub mod sort;
90pub mod source;
91pub mod sources;
92pub mod sprite;
93pub mod string;
94mod style;
95pub mod subdivision_granularity;
96pub mod terrain;
97pub mod tile_id;
98pub mod tileset;
99pub mod time;
100pub mod types;
101pub mod unitbezier;
102#[doc(hidden)]
103pub mod wire;
104
105pub use layer::{Layer, LayerList, LayerTypeInfo};
106pub use property::evaluation::{CrossfadeParameters, PropertyEvaluationParameters};
107pub use property::transition::{GlobalStateChange, TransitionOptions, TransitionParameters};
108pub use property::value::{PropertyValue, StyleValue};
109pub use registry::StyleRegistry;
110pub use source::{Source, SourceInstance, SourceList, SourceTypeInfo};
111pub use style::edit::{Edit, SourceUpdate};
112pub use style::parse::{Parser, parse_fallback_font_faces};
113pub use style::{Style, StyleCamera, StyleLoadError, diff};
114
115/// What the expansions of [`properties!`] and [`layer_properties!`] name,
116/// so that a crate that invokes them needn't depend on it.
117#[doc(hidden)]
118pub mod __private {
119 pub use mln_wire;
120
121 pub use crate::property::table::{property_name, slots_by_name};
122}
123
124/// The `tracing` targets of this crate's events. Each names the event that
125/// `mln_c` reports it under (`mln_c::logging`).
126mod log_target {
127 pub(crate) const GENERAL: &str = "mln_style::general";
128 pub(crate) const PARSE_STYLE: &str = "mln_style::parse_style";
129 pub(crate) const STYLE: &str = "mln_style::style";
130}
131
132#[cfg(test)]
133mod tests;