Skip to main content

mln_runtime/
lib.rs

1//! Thread-safe handles over mln-rs's maps, which mirror
2//! maplibre-native-ffi's C API one to one.
3//!
4//! A [`Runtime`] owns a thread, and the file sources, cache and offline
5//! regions of its maps. Each [`Map`] lives on its runtime's thread, and its
6//! handle sends commands there: they run in the order sent, across the
7//! runtime and all its maps, and report through a [`Completion`]. A map
8//! publishes a [`MapSnapshot`] after each command, which any thread reads
9//! without waiting, and the events of the runtime and its maps reach one
10//! handler in batches. A [`RenderSession`] that [`Map::attach`] creates
11//! draws a map's frames offscreen or onto a surface, on a thread of its own,
12//! or on the host's graphics thread through its [`DriverWork`].
13//!
14//! The synchronous, single-thread core that these handles drive is
15//! `mln_map`'s; [`Map::with_core`] runs a closure on it.
16//!
17//! Sessions render with the backends of the crate's features: `webgpu`,
18//! `metal`, `vulkan` and `gl`, each where its platform has it. A session's
19//! [`Device`] picks its backend.
20
21#[cfg(not(any(feature = "webgpu", feature = "metal", feature = "vulkan", feature = "gl")))]
22compile_error!("mln_runtime renders with at least one backend: enable `webgpu`, `metal`, `vulkan` or `gl`");
23
24mod camera;
25mod completion;
26mod event;
27mod feature_state;
28mod map;
29mod offline;
30mod render;
31mod resources;
32mod runtime;
33mod style;
34
35pub use camera::{CameraFitArea, CameraFitOptions, CameraFitUpdate, TileOptions, ViewportOptions};
36pub use completion::Completion;
37pub use event::{EventHandler, EventMask, EventSource, EventType, RuntimeEvent, RuntimeEventKind};
38pub use feature_state::{FeatureState, FeatureStateSelector};
39pub use map::{Applied, CameraQuery, CommandGroup, Map, MapId, MapOptions};
40pub use mln_map::{LogicalExtent, MapSnapshot};
41pub use mln_renderer::query::{RenderedQueryOptions, SourceQueryOptions};
42pub use mln_util::{Error, ErrorKind};
43pub use offline::Offline;
44pub use render::{
45    AcquiredFrame, Adapter, AttachOptions, BackendType, BorrowedRing, ConsumerSync, DemandMode, Device, DeviceOptions,
46    DmaBufFormat, DmaBufPlane, Driver, DriverWork, ExportKind, ExportKinds, ExportedImage, ExportedRing, FrameDemand,
47    FrameDisposition, FrameResult, FrameTexture, FrameTextureKind, FrameView, GlApi, GpuSync, LocalTarget,
48    RenderSession, RenderSessionCapabilities, RenderSessionSnapshot, RenderSessionState, RenderTarget,
49    RenderedQueryGeometry, Surface, SurfaceType, SyncKind, SyncKinds, Wake,
50};
51pub use resources::{CacheDatabaseOperation, ResourceProvider, ResourceRequest, is_managed_http_header};
52pub use runtime::{Runtime, RuntimeOptions};
53pub use style::{CustomSourceCallbacks, GeoJsonSourceOptions, LayerInfo, SourceInfo, SourceKind, SourceTiles};