The Rust engine¶
roadstyle 0.25 has a second engine, written in Rust. It makes the same maps as the Python engine, 3 to 12 times faster.
Experimental
The Rust engine is experimental in 0.25. The Python API that selects it (engine="rust", ROADSTYLE_ENGINE) is stable.
The engine's inside, the roadstyle:* metadata in the style and the __rs_* property names can change in the next
versions. The default engine stays Python.
The Rust engine makes the style of a map, its vector tiles, the drawing levels and the HTML page. It is in the roadstyle wheel
on PyPI, so pip install roadstyle gives you both engines. The default engine is Python. You select the Rust engine for each
call or for the whole process:
The same engine is also a WebAssembly package for the browser, and a set of Rust crates.
-
Tutorial
Draw Monaco with the Rust engine, compare it with the Python engine and measure the time.
-
How-to guides
Switch the engine · Use roadstyle in the browser · Make tiles and PMTiles · Build from source
-
Reference
-
Explanation
Architecture of the Rust version · How a map is drawn · Parity and speed
When to use it¶
- Large networks. On Tartu (64,828 roads) the page takes 6.2 s with Rust and 19.1 s with Python. With
tiles=Trueit takes 12.2 s and 147.5 s (Parity and speed). - Nightly pages. The output is the same as the Python output, byte for byte, so you can change the engine without a change to your pages.
- The browser. A page can make the style and the tiles itself, from a duckOSM file or a GeoParquet file, with no Python.
The Rust engine does not do everything that the Python engine does. For example, the folium and lonboard backends and a
Styler object (style=) stay in Python. Keywords by engine gives the state of each keyword.