Introducing a new way to review your PRs.

Read the announcement

maplibre / maplibre-tile-spec

Next generation map vector tiles format

View on GitHub

20 documents · Updated Nov 23, 2026

docs / rust-tile-workspace

Rust tile workspace

The Rust tile workspace coordinates six crates that provide one MLT codec foundation for native programs, Python applications, command-line tools, and web applications. The core library defines the shared tile model and wire-format behavior. Each delivery target adapts that capability to its host language and release channel.

Workspace purpose

The workspace keeps tile reading, writing, conversion, and inspection on one shared data contract. This lets each package serve a different audience without creating separate rules for the MLT format.

Workspace boundaries

The workspace includes the core codec and five target or support crates. Cargo treats the native, command-line, core, and synthetic-data crates as the default members for routine workspace work. Python and WebAssembly remain workspace members with their own package delivery paths. Shared package metadata sets the Rust 2024 edition and Rust 1.98 as the minimum toolchain. The lock file records the resolved dependency graph for all six crates.

References: rust/Cargo.toml• L1-17 rust/Cargo.lock• L2844-2981

Core tile codecs

The rust/mlt-core crate is the format engine used by the other Rust packages. It supports tile decoding and encoding for geometry, properties, dictionaries, and multiple wire-format versions. Its encoder can choose data layouts that trade tile size against processing cost, including layouts for repeated vertices and shared string values. Shared workspace dependency policy keeps the codec's compression and format support aligned across delivery targets. See Rust core codecs.

References: rust/…/Cargo.toml• L1-12 rust/Cargo.toml• L19-92 rust/…/streams.rs• L352-399 rust/…/shared_dict.rs• L53-115

Delivery targets

The workspace presents the core codec through targets that match different host environments. The targets share the codec model, while their package APIs and native data boundaries serve different users.

TargetMain audienceProduct role
mlt-ffiC, C++, Java, and Kotlin callersNative conversion, layer building, and tile inspection
mlt-wasmBrowser and JavaScript applicationsWeb tile decoding and renderer-friendly data access
mlt-pyPython applicationsTile decoding, encoding, and geospatial data exchange
mltEngineers and operatorsLocal inspection, conversion, and debugging
mlt-syntheticsWorkspace and test toolingPrivate repeatable tile-data generation

The native and WebAssembly boundaries have their own pages: Rust native bindings and Rust WebAssembly package. Python delivery is provided through the maplibre-tiles package.

References: rust/Cargo.toml• L1-7 rust/…/Cargo.toml• L1-26 rust/…/Cargo.toml• L1-36 rust/…/Cargo.toml• L1-37 rust/…/Cargo.toml• L1-67 rust/…/Cargo.toml• L1-18

Tile data flow

The workspace uses one broad path from encoded tile bytes to application data and back. A target gives the core decoder input bytes, receives layer or feature data, and can send application data to the encoder for a new MLT tile or a conversion target such as MVT.

Decode and encode lifecycle

The lifecycle separates format work from host-language use. A consumer can inspect or decode a tile, while an encoder can choose a suitable representation for new features.

This diagram shows how the shared codec connects input tiles, host targets, and output formats.

flowchart LR
    A["MLT tile bytes"] --> B["Shared core codec"]
    B --> C["Layer and feature data"]
    C --> D["Native, Python, CLI, or WebAssembly consumer"]
    D --> E["Application data, renderer data, or MVT"]
    F["Application features"] --> B
    B --> G["Encoded MLT tile bytes"]

The delivery crates currently opt into the core's unstable v2 capability. This gives native, Python, CLI, and web consumers access to the same evolving v2 data model instead of making each target define its own version behavior. WebAssembly enables this capability by default, while the other delivery crates request it through their core dependency.

References: rust/…/Cargo.toml• L49-55 rust/…/Cargo.toml• L17-21 rust/…/Cargo.toml• L25-30 rust/…/Cargo.toml• L20-34 rust/…/Cargo.toml• L21-44

Delivery model

The workspace delivers the codec in forms that fit each host's memory and language rules. Native packages carry a foreign-function interface and platform libraries. The web package combines Rust compiled to WebAssembly with JavaScript and TypeScript output. Python receives a native extension package.

Native package boundary

The rust/mlt-ffi crate defines the shared native boundary. Generated C, C++, Kotlin, and Java surfaces let those languages call the same native library. The Java and Kotlin packages also package platform-specific native libraries so an application can load the library from its package at run time.

The generated Java raw bindings describe the current C ABI for native types, structure layouts, and exported symbols. Their regenerated layouts now reflect the host C library definitions used by the Java foreign-function boundary.

The current native release set includes Linux, macOS, Windows, and FreeBSD targets for supported x86-64 and AArch64 environments. Java also supports an explicit library-path override when a packaged platform library is not suitable.

References: rust/…/Cargo.toml• L14-26 rust/…/build.gradle• L61-89 rust/…/NativeLibrary.java• L10-41 rust/…/_IO_FILE.java• L15-94 rust/…/mlt_ffi_h.java• L15-70 rust/…/build.gradle• L56-86 rust/…/NativeLibraryTest.java• L18-59

WebAssembly package boundary

The rust/mlt-wasm crate turns the shared decoder into the @maplibre/mlt-wasm package. The package exposes JavaScript entry points and TypeScript declarations, while the WebAssembly module performs the tile work. Its intended outputs include ordinary decoded features, column-oriented data for renderers, 3D data, and wire-format inspection.

The web build produces the WebAssembly module, its JavaScript support files, TypeScript output, and a compressed WebAssembly copy as one package build. The published npm artifact exposes dist as its JavaScript and type entry point and includes both dist and pkg. See Rust WebAssembly package.

References: rust/…/Cargo.toml• L1-37 rust/…/package.json• L1-38 rust/…/package.json• L40-52 rust/mod.just• L522-534 rust/mod.just• L641-650

Python package boundary

The rust/mlt-py crate serves Python code through the maplibre-tiles package. It gives Python applications access to structured MLT data and conversion flows without requiring them to use the Rust codec model directly. Maturin builds the Rust extension and exposes it as the maplibre_tiles Python module.

The Python package follows the core release version and targets Python 3.10 or newer. Its boundary supports both decoding and encoding workflows, including exchange with common geospatial tile data. The optional abi3 feature keeps the extension compatible with Python 3.10 and newer, and can also generate an import library.

References: rust/…/Cargo.toml• L1-36 rust/…/pyproject.toml• L1-10 rust/…/pyproject.toml• L38-40 rust/mod.just• L367-389 rust/mod.just• L499-510

Workspace support systems

The workspace includes local tools and release checks that keep the shared codec and its delivery targets usable. These systems validate cross-language behavior, create repeatable tile data, and prepare packages for publication.

Inspection tools

The rust/mlt command-line tool is the local entry point for tile inspection and conversion. It lets engineers view, list, decode, and convert MLT data through the same core behavior used by the libraries. Its package metadata also defines downloadable release archives for supported targets.

References: rust/…/Cargo.toml• L1-19 rust/…/Cargo.toml• L27-67 rust/mod.just• L179-203

Quality and publication flow

The workspace checks Rust crates together and then checks the boundaries that need other runtimes. The shared checks cover formatting, feature combinations, documentation, tests, fuzzing, and package dry runs. Separate recipes build WebAssembly with its JavaScript package and run native FFI round trips for C, C++, Kotlin, and Java.

Release work keeps crate versions and generated package versions aligned. Rust packages publish through the workspace release flow. The WebAssembly package publishes to npm, while native release artifacts feed the Java and Kotlin package builds. The lock file preserves the exact dependency resolution used by these package builds.

References: rust/mod.just• L113-142 rust/mod.just• L394-415 rust/mod.just• L433-497 rust/mod.just• L536-577 rust/mod.just• L623-655 rust/Cargo.lock• L1-4

Change checklist

When these files or sections are changed, remember to consider these:

  • Changes to the core tile model or encoder output require matching checks in the FFI, Python, CLI, and WebAssembly targets.
  • Changes to the core version or workspace package metadata must stay aligned with the dependent crate versions and their changelogs.
  • Changes to WebAssembly exports must stay aligned with the TypeScript build, package entry points, generated pkg and dist outputs, compressed WebAssembly output, and npm version fields.
  • Changes to the native ABI must be followed through generated language bindings, including Java raw structure layouts and platform resource names, and Java or Kotlin round-trip packages.
  • Changes to v2 support must be checked across every target that enables unstable-v2 or receives the feature through its core dependency.
  • Changes to release recipes must preserve the link between native library artifacts and the Java/Kotlin package classifiers.
  • Changes to workspace dependency versions must keep rust/Cargo.lock aligned with the crate manifests and the WebAssembly build toolchain.
  • Changes to the Python abi3 feature must preserve the supported Python version range and stub-generation path.

Important failure modes

TriggerConsequenceGuard
A delivery target exposes a data shape that differs from the core modelThe same tile behaves differently across native, Python, CLI, and web consumersKeep target adapters on the shared core contract and use cross-target round trips
WebAssembly exports and TypeScript entry points drift apartThe npm package builds but imports or runtime calls failBuild the WebAssembly and TypeScript outputs together
The published package omits dist, pkg, or the expected compressed moduleBrowser consumers cannot load the package or lose the intended transfer-size optionKeep package file selection and the combined build output aligned
A Java or Kotlin package lacks the native library for its platformThe package fails when it tries to load the native libraryKeep classifier mappings, packaged resource paths, and platform tests aligned
Generated Java raw layouts do not match the current C ABIJava foreign-memory access can read the wrong native fieldsRegenerate the Java bindings and run native round trips
A v2 capability is enabled in only part of the workspaceConsumers see different features or geometry for the same tileCheck the unstable-v2 setting for every delivery crate
A crate version changes without the matching generated package versionRust, Python, native, and npm consumers receive mismatched releasesRun the version-sync recipes and workspace publication checks
A crate manifest changes without a matching lock-file updateBuilds resolve a different dependency graph than the workspace expectsRegenerate and review rust/Cargo.lock with the manifest change
The Python extension loses its abi3 support or stub-generation featureSupported Python versions or generated type information become unavailableKeep the feature contract and Python package build aligned

Key files

FileWhy to read it
rust/Cargo.tomlDefines the workspace members, default members, shared package metadata, Rust version, common dependency policy, and workspace lint policy.
rust/Cargo.lockRecords the resolved dependency graph for the workspace packages and their delivery targets.
rust/…/Cargo.tomlShows the core codec's public and evolving feature sets.
rust/…/CHANGELOG.mdShows how codec and wire-format changes affect the shared foundation over time.
rust/…/Cargo.tomlDefines the native crate and its connection to the core codec.
rust/…/NativeLibrary.javaShows how Java consumers find a packaged or overridden native library.
rust/…/_IO_FILE.javaShows the generated Java view of the native structure layout used by the FFI boundary.
rust/…/Cargo.tomlDefines the WebAssembly crate, its default v2 capability, and its optional coverage feature.
rust/…/package.jsonDefines the browser package entry points, published paths, and combined WebAssembly, TypeScript, and compressed-output build.
rust/…/Cargo.tomlDefines the Python extension, its Python compatibility feature, and its connection to the core codec.
rust/…/pyproject.tomlDefines the published Python package and its Rust extension build.
rust/…/Cargo.tomlDefines the command-line tool, its conversion dependencies, and release archive metadata.
rust/…/Cargo.tomlDefines the private workspace tool for repeatable tile-data generation.
rust/mod.justConnects workspace checks, package builds, generated bindings, native tests, and release preparation.