mln-rs-style 0.0.21

Part of mln-rs, a MapLibre map renderer written in Rust. Depend on mln-rs instead.
Documentation
//! The map style: [`Style`], the style JSON parser, layers and sources, the
//! property system (`property`), the expression language (`expression`), what
//! expressions read of a feature (`feature`), the spec's value types (`types`)
//! and the conversions from JSON-like values to style types (`conversion`).
//!
//! It also holds the vocabulary that the style shares with the engine:
//! errors, colors, padding, sizes, ranges, interpolation and easing
//! (`unitbezier`), images' pixels (`bitmap`), coordinates (`geo`), tilesets,
//! feature types (`geometry`), canonical tile ids (`tile_id`), the spec's
//! constants, math, number formatting (`string`), hash maps, clocks
//! (`time`), the Unicode script checks (`i18n`) and the projection's
//! subdivision granularity.
//!
//! A style parses against a [`StyleRegistry`]: the expression functions,
//! layer types and source types its JSON, property values and filters may
//! name, the extension members (`member`) that give the style's and its
//! layers' `<namespace>:<name>` members a type, and the projections (`crs`)
//! its `projection.type` may name.
//!
//! Versions:
//! - A [`Style`] is a value: a version of a map's style. Its parts sit
//!   behind `Arc`s, so versions share what they don't change, and a part
//!   whose `Arc` is the same pointer in two versions is the same part.
//! - [`Style::apply`] makes an [`Edit`], the only way to change a style; the
//!   JSON entry points (`add_layer_json`, `set_layer_property_json`, ...)
//!   parse and then apply one.
//! - [`Style::is_same_version`] says in O(1) whether two versions are the
//!   same, and [`diff::StyleDiff::between`] what a renderer has to redo for
//!   each layer, source and image to go from one version to another.
//! - Loading isn't here: the map's loader fetches documents, sprites and
//!   source descriptions, and [`Style::from_json`] parses a document. A
//!   style holds its sources as values ([`SourceList`]), and what their
//!   loads find, of a type that the source type's engine half names,
//!   arrives as edits.
//!
//! Layers:
//! - `layer::Layer` is a layer of any type. Its style data is an
//!   `Arc<dyn layer::ErasedLayerStyle>`, a `layer::LayerStyle<T>`
//!   of its type `T`; `layer::LayerBase` holds the members every layer
//!   type has.
//! - Each layer type is a marker type that implements
//!   `layer::StyleLayerType`, such as `layers::Background`, with
//!   property sets such as
//!   `layers::BackgroundPaintProperties::{Transitionable, Unevaluated, PossiblyEvaluated, Evaluated}`.
//! - Each layer type, the light and the sky have a property table, which
//!   `property::table` reads to get, set and serialize properties by name.
//!   `layers/<type>_layer_properties.rs`, `light_properties.rs` and
//!   `sky_properties.rs` are generated by //tools/style-codegen from the style
//!   spec.

#[cfg(target_os = "android")]
pub mod android;
pub mod bitmap;
pub mod collections;
pub mod color;
pub mod constants;
pub mod conversion;
pub mod crs;
pub mod error;
pub mod expression;
pub mod feature;
pub mod filter;
pub mod font_face;
pub mod geo;
pub mod geometry;
pub mod hash;
pub mod i18n;
pub mod image;
pub mod interpolate;
pub mod layer;
pub mod layers;
pub mod light;
#[rustfmt::skip]
mod light_properties;
pub mod math;
pub mod member;
pub mod padding;
pub mod projection;
pub mod property;
pub mod range;
pub mod registry;
pub mod size;
pub mod sky;
#[rustfmt::skip]
mod sky_properties;
pub mod source;
pub mod sources;
pub mod sprite;
pub mod string;
mod style;
pub mod subdivision_granularity;
pub mod terrain;
pub mod tile_id;
pub mod tileset;
pub mod time;
pub mod types;
pub mod unitbezier;
#[doc(hidden)]
pub mod wire;

pub use layer::{Layer, LayerList, LayerTypeInfo};
pub use property::evaluation::{CrossfadeParameters, PropertyEvaluationParameters};
// The property macros, at the root so that the generated code and the
// macros themselves name them as `crate::name!`.
pub use property::transition::{GlobalStateChange, TransitionOptions, TransitionParameters};
pub use property::value::{PropertyValue, StyleValue};
pub use registry::StyleRegistry;
pub use source::{Source, SourceInstance, SourceList, SourceTypeInfo};
pub use style::edit::{Edit, SourceUpdate};
pub use style::parse::{Parser, parse_fallback_font_faces};
pub use style::{Style, StyleCamera, StyleLoadError, diff};

/// The `tracing` targets of this crate's events. Each names the event that
/// `mln_c` reports it under (`mln_c::logging`).
/// What the expansions of [`properties!`] and [`layer_properties!`] name,
/// so that a crate that invokes them needn't depend on it.
#[doc(hidden)]
pub mod __private {
    pub use mln_wire;

    pub use crate::property::table::{property_name, slots_by_name};
}

mod log_target {
    pub(crate) const GENERAL: &str = "mln_style::general";
    pub(crate) const PARSE_STYLE: &str = "mln_style::parse_style";
    pub(crate) const STYLE: &str = "mln_style::style";
}

#[cfg(test)]
mod tests;