Skip to main content

Crate mln_runtime

Crate mln_runtime 

Source
Expand description

Thread-safe handles over mln-rs’s maps, which mirror the C API (mln-rs-c) one to one.

A Runtime owns a thread, and the file sources, cache and offline regions of its maps. Each Map lives on its runtime’s thread, and its handle sends commands there: they run in the order sent, across the runtime and all its maps, and report through a Completion. A map publishes a MapSnapshot after each command, which any thread reads without waiting, and the events of the runtime and its maps reach one handler in batches. A RenderSession that Map::attach creates draws a map’s frames offscreen or onto a surface, on a thread of its own, or on the host’s graphics thread through its DriverWork.

The synchronous, single-thread core that these handles drive is mln_map’s; Map::with_core runs a closure on it.

Sessions render with the backends of the crate’s features: webgpu, metal, vulkan and gl, each where its platform has it. A session’s Device picks its backend.

In the browser (wasm32-unknown-unknown, without threads), a runtime’s thread and its sessions’ are the one that made the runtime: their work runs in short tasks on that thread’s event loop (mln_web_host‘s pump), never inside the call that sent it, and nothing blocks. Sessions present to a canvas (Surface::web_canvas) with the browser’s WebGPU or WebGL2, and put their tiles’ workers in Web Workers.

Modules§

registry
The registrations that a runtime’s maps, their renderers and their tile workers share: the expression functions and the layer types.

Structs§

AcquiredFrame
A frame of a borrowed ring that the host acquired, until it gives it back. Dropping it gives it back as release with SyncKind::CpuComplete does.
Applied
What a map command left behind once it ran.
AttachOptions
How a session attaches to its map.
BorrowedRing
A ring of the host’s textures, of one backend.
CameraFitOptions
How a camera fits an area.
CameraFitUpdate
Moves the camera to fit an area: CameraUpdate’s counterpart for Map::fit_camera.
CameraQuery
The camera, and the generation of the map that it belongs to.
CommandGroup
A command group of a map that ends when it drops.
Completion
The result of a command, which arrives once the command has run.
ConsumerSync
What the host’s reads of a frame’s texture end with, which a target waits for before it draws into the texture again. The target takes the sync file, or the GLsync that sync names; dropping it closes the sync file.
CustomSourceCallbacks
The callbacks of a custom source, which run on a library thread. A map asks for a tile with fetch_tile, and answers come back through the source’s commands, such as Map::set_custom_geometry_source_tile_data. cancel_tile reports that the map no longer needs a tile.
DepthStencilFormats
A set of DepthStencilFormats.
DeviceOptions
How to create a Device.
DmaBufFormat
A DRM format and modifier that the host imports.
DmaBufPlane
Where one plane of a dmabuf keeps its data.
DriverWork
The graphics work of a render session that attached with Driver::CallerThread, which runs only when the host’s graphics thread calls service.
Error
A failed call: its ErrorKind and a message that says what failed.
EventMask
A set of event types. The bits are the C API’s mln_runtime_event_flag: 1 << type for each type.
ExportKinds
A set of ExportKinds.
ExportedRing
A ring of images that the target allocates, as the host asks for it: depth images, shared in a kind of kinds.
FeatureStateSelector
The features whose state to set, read or remove.
FrameDemand
A demand for one frame.
FrameDepth
The texture that holds a frame’s depth and stencil.
FrameProjection
Where a frame drew the map, and the depth its 3D layers wrote there.
FrameResult
How one frame demand finished.
FrameTexture
The host’s texture that an acquired frame was rendered into, of size pixels.
FrameView
A view of an acquired frame, which AcquiredFrame::view opens, until it drops.
GeoJsonSourceOptions
The options of a GeoJSON source, which stay fixed for as long as the style holds it. The defaults are the style specification’s.
GpuSync
A point in one side’s GPU work that the other side waits for before it uses a shared texture: the object to wait on, as an integer, for the kinds that name one, and the value a timeline reaches.
LayerInfo
A layer of the map’s style.
LocalTarget
A render target built on this thread: the backend that a renderer draws with, on the target’s device, and the frames it draws into.
LogicalExtent
A size in logical pixels, and the physical pixels in each logical pixel.
Map
A handle to a map, which lives on its runtime’s thread.
MapId
The ID of a map, unique within its runtime.
MapOptions
How to create a map.
MapSnapshot
A map’s state at one moment.
Offline
The offline regions in a runtime’s cache database, from Runtime::offline. Each call is a command of the runtime, and the regions download on the database’s thread.
RenderSession
A render session: a renderer that draws a map into a target, on a thread of its own or on the host’s.
RenderSessionCapabilities
What a render session can do.
RenderSessionSnapshot
The state of a render session at one moment.
RenderedQueryOptions
Options for query rendered features.
ResourceRequest
A network request that a ResourceProvider serves.
Runtime
A runtime: a thread of its own that holds maps, and the resource loading, cache and offline regions that they share.
RuntimeEvent
An event of a runtime or of one of its maps.
RuntimeOptions
Where a runtime keeps its assets and its cache, and the network status its requests follow.
SourceInfo
A source of the map’s style.
SourceQueryOptions
Options for query source features
SourceTiles
The tiles that a source lists in the style itself, rather than at a URL.
Surface
What a surface session presents to.
SyncKinds
A set of SyncKinds.
TileOptions
How the map picks the tiles to load, as its snapshot’s TileSettings report it. A setting that is None keeps its value.
ViewportOptions
How the map orients and constrains its view. A setting that is None keeps its value.

Enums§

Adapter
A GPU, by what names it to a backend.
BackendType
CacheDatabaseOperation
A maintenance action on a runtime’s cache database.
CameraFitArea
An area for a camera to fit in the map’s view.
CanvasFormat
A GPUTextureFormat that a WebGPU canvas takes.
ClipDepthRange
How a graphics API’s clip space holds depth.
DemandMode
When a demand draws a frame.
DepthStencilFormat
A format of depth and stencil textures.
Device
A GPU that sessions on many maps and threads share: one backend’s device. Sessions on it keep working after the last handle drops, until they detach.
Driver
The thread that runs a render session’s graphics work.
ErrorKind
What went wrong, as a caller would react to it.
EventSource
What raised an event.
EventType
The type of an event. The values are the C API’s mln_runtime_event_type.
ExportKind
A way to share a texture’s memory with another API or process.
ExportedImage
The shared memory of a frame’s image. The objects it names are the target’s, and stay valid until the host gives the frame back.
FrameDisposition
How a frame demand finished.
FrameTextureKind
A FrameTexture’s backend objects.
GlApi
The OpenGL API that an OpenGL device renders with. By default the platform’s: desktop OpenGL on Windows, and OpenGL ES elsewhere.
NativeTexture
A texture as the API of the device that drew into it names it.
RenderSessionState
Where a render session is in its life.
RenderTarget
What a render session renders into. The session builds it into the backend’s objects on the thread that renders, on device, or on a device that Device::new makes when that is None. The device’s backend is the session’s.
RenderedQueryGeometry
The screen area that a rendered feature query covers, in logical pixels from the top left corner.
RuntimeEventKind
What an event reports.
SourceKind
The kind of a style source.
SurfaceOverlay
What a host draws over each frame that a surface session presents, after the map and before the frame is presented (and read back): the overlay of the backend that the session presents with (DriverWork::set_overlay).
SurfaceType
A kind of window or layer that a session presents to.
SyncKind
How one side of a shared texture waits for the other’s GPU work on it.

Traits§

ResourceProvider
Serves a runtime’s network requests in place of the library.

Functions§

is_managed_http_header
Whether the library or the platform manages the HTTP header name, in any letter case, so that a header transform can’t set it.

Type Aliases§

EventHandler
The runtime’s event handler. It runs on the runtime’s thread with each batch of events, oldest first.
FeatureState
The state of one feature: keys and their values.
Wake
A callback that tells the host about something it should act on, such as frame results to drain. It runs on a library thread and must not block.