Expand description
Safe Rust binding for the MapLibre Native C API.
Each handle type is the one owner of its native handle: it can’t be
cloned, a consuming call such as release takes it and hands it back when
native refuses, and Drop disposes it. Native keeps a parent alive while
its children need it, so a child owner holds no reference to its parent’s.
Handles are any-thread; native rejects a graphics call from the wrong
thread with Status::WrongThread.
Values that native lends until a call ends borrow what lends them. An
acquired frame’s backend textures borrow its AcquiredFrameView, which
keeps them valid until it drops, and a callback’s response borrows the
callback. Inputs borrow the caller’s text and bytes for the call.
Native registrations retain their callback closures until they are cleared
or their owner retires. A callback that shares an owner with the host,
through an Arc, should capture a std::sync::Weak reference to it.
Capturing a strong Arc creates a reference cycle that requires an
explicit clear or release.
The binding contains callback errors and panics and returns a failure value
to native. Failures that no caller can receive go to the reporter that
set_reporter installs, as Report::CallbackError, or to standard error
when none is installed. A completion conversion panic resolves its future
with an error. A panic also reaches the standard panic hook as usual.
The metal, opengl, vulkan, and webgpu features pick the one render
backend the native library is built with, so they don’t combine. Only the
final binary enables one; a library that depends on this crate leaves them
off.
In the browser, RuntimeHandle::create returns Status::WrongThread on the
main thread, and NativeFuture::wait blocks, so a host runs the binding
on a worker, such as the one Emscripten’s -sPROXY_TO_PTHREAD provides.
Re-exports§
pub use maplibre_native_ffi_sys as sys;
Structs§
- Acquired
Frame Handle - Owns one native handle.
- Acquired
Frame View - A view scope of
AcquiredFrameHandle, which ends when it drops. Its getters lend values that stay valid until then, and its owner can’t be consumed while it lives. - Anchored
Momentum - How a gesture’s zoom, bearing, or pitch keeps changing after release.
- Android
Hardware Buffer Frame - The Android hardware buffer of an acquired frame.
- Android
Hardware Buffer Ring Descriptor - A ring of Android hardware buffers that the library allocates, for
MapHandle::attach_android_hardware_buffer_ring(). - Android
Surface Descriptor - An Android window to present to, for
MapHandle::attach_android_surface(). - Android
Surface Replacement - A new Android window for
RenderSessionHandle::set_android_surface_target(). - Animation
Options - How a camera change animates.
- Bound
Options - Limits on the camera, for
MapHandle::set_bounds(). - Camera
- A map’s whole camera.
- Camera
Bounds - All the limits on a map’s camera.
- Camera
Delta - A change to the camera from where it is now, for gestures.
- Camera
FitOptions - Options for finding the camera that fits an area.
- Camera
FitUpdate - A camera change that fits an area, for
MapHandle::fit_camera_to_lat_lng_bounds()and the other fit commands. - Camera
Options - A camera, with only the members that
fieldsselects. - Camera
Query Result - A map’s camera, with the snapshot generation that it matches.
- Camera
Transition End - The end of a camera change.
- Camera
Transition Handler - A callback for the end of a camera change, for
AnimationOptions. - Camera
Update - A camera change for
MapHandle::update_camera(). - Camera
Velocity - How fast each part of a camera change moves.
- Canonical
Tile Id - A tile’s zoom level
z, columnx, and rowy, with row 0 at the north. - Command
Completion - The generations that a committed command published, which are zero unless it is a map command.
- Custom
Geometry Source Options - The callbacks and options of a custom geometry source.
- Custom
Vector Source Options - The callbacks and options of a custom vector source.
- DmaBuf
Format - A DRM format and modifier that you can import.
- DmaBuf
Frame - The dmabuf of an acquired frame.
- DmaBuf
Plane - Where one plane of a dmabuf keeps its data.
- DmaBuf
Ring Descriptor - A ring of dmabufs that the library allocates, for
MapHandle::attach_dma_buf_ring(). - Dxgi
Shared Texture Frame - The DXGI shared texture of an acquired frame.
- Dxgi
Shared Texture Ring Descriptor - A ring of DXGI shared textures that the library allocates, for
MapHandle::attach_dxgi_shared_texture_ring(). - Edge
Insets - Distances in logical pixels from each edge of the map.
- EglContext
Descriptor - The EGL objects that a render session makes its OpenGL context from.
- Feature
State Selector - The features whose state to set, read, or remove.
- Frame
Demand - A demand for one frame.
- Frame
Demand Flag - How a frame demand behaves.
- Frame
Pacer Handle - Owns one native handle.
- Frame
Pacer Options - Options for creating a frame pacer.
- Free
Camera - A map camera’s whole position and orientation in three dimensions.
- Free
Camera Options - The camera’s position and orientation in three dimensions.
- GeoJson
Source Options - Options for a GeoJSON [source](https://maplibre.org/maplibre-style-spec/sources/#geojson).
- Gesture
Momentum - How a gesture keeps moving the camera after the user lets go.
- GpuSync
- A point in GPU work that the other side waits for before using a texture.
- GpuSync
Kind Flag - A GPU sync kind, as a bit in a set.
- Http
Header - An HTTP header.
- Http
Header Rule - Headers to add to the HTTP requests whose URL matches a pattern.
- Http
Header Transform - Headers to add to HTTP requests, for
RuntimeHandle::set_http_header_transform(). - Http
Header Transform Response - A native response borrowed only for one host callback.
- Image
Content - The area of an image, in image pixels, that text fits inside.
- Image
Stretch - A range of image pixels, from
fromtoto, that stretches to fit text. - IoSurface
Frame - The IOSurface of an acquired frame.
- IoSurface
Ring Descriptor - A ring of IOSurfaces that the library allocates, for
MapHandle::attach_io_surface_ring(). - LatLng
- A geographic coordinate, in degrees.
- LatLng
Bounds - A rectangle of coordinates, from its southwest to its northeast corner.
- Lent
- A value that a view getter lends, valid until its view drops.
- LogHandler
- A log callback, for
set_log_callback(). - LogSeverity
Flag - A log severity, as a bit in a set.
- Logical
Extent - A size in logical pixels, and the physical pixels in each logical pixel.
- Logical
Size - A size in logical pixels, which the map’s scale factor turns into pixels.
- MapDebug
Flag - A debug overlay that the map draws.
- MapHandle
- Owns one native handle.
- MapHandle
Discarding - Submits
MapHandlecommands without a completion. Each call returns the same acceptance status as its completing form, and native logs a command that later fails as a warning through the log handler. - MapOptions
- Options for
RuntimeHandle::create_map(). - MapProjection
Camera Result - A projection’s camera, as
MapProjectionHandle::get_camera()reports it. - MapProjection
Handle - Owns one native handle.
- MapSnapshot
- A map’s state, as
MapHandle::get_snapshot()reads it. - MapTile
Options - How the map picks the tiles to load.
- MapTile
Settings - All the settings for how a map picks the tiles to load.
- MapView
- One view of a map: its camera, size, and projection.
- MapViewport
- A map’s whole viewport.
- MapViewport
Options - How the map orients and constrains its view.
- Metal
Borrowed Texture - A Metal texture of a borrowed ring.
- Metal
Borrowed Texture Descriptor - A ring of your Metal textures, for
MapHandle::attach_metal_borrowed_texture(). - Metal
Borrowed Texture Replacement - New Metal textures for a borrowed ring, for
RenderSessionHandle::set_metal_borrowed_texture_target(). - Metal
Context Descriptor - The Metal device that a render session uses.
- Metal
Surface Descriptor - A Metal layer to render to, for
MapHandle::attach_metal_surface(). - Metal
Surface Replacement - A new Metal layer for
RenderSessionHandle::set_metal_surface_target(). - Metal
Texture Frame - The Metal texture of an acquired frame.
- Momentum
Decay - How one part of a gesture’s momentum slows from its release speed.
- Momentum
Snap - Where a part settles after a gesture that changed it.
- Native
Future - A one-shot native completion exposed as a Rust future.
- Native
Handle Leak - A native handle a destructor attempted to destroy and could not. The handle stays live.
- Offline
Geometry Region Definition - An offline region that covers a GeoJSON geometry.
- Offline
Region Info - An offline region in the runtime’s cache file.
- Offline
Region Status - The download progress of an offline region.
- Offline
Tile Pyramid Region Definition - An offline region that covers a rectangle of the map.
- Offscreen
Descriptor - The image that
MapHandle::attach_offscreen()renders. The session renders it at the map’s scale factor. - Offscreen
Device Handle - Owns one native handle.
- Offscreen
Device Options - Options for
OffscreenDeviceHandle::create(). - Ohos
Surface Descriptor - An OpenHarmony window to present to, for
MapHandle::attach_ohos_surface(). - Ohos
Surface Replacement - A new OpenHarmony window for
RenderSessionHandle::set_ohos_surface_target(). - Open
GlBorrowed Texture - An OpenGL texture of a borrowed ring.
- Open
GlBorrowed Texture Descriptor - A ring of your OpenGL textures, for
MapHandle::attach_open_gl_borrowed_texture(). - Open
GlBorrowed Texture Replacement - New OpenGL textures for a borrowed ring, for
RenderSessionHandle::set_open_gl_borrowed_texture_target(). - Open
GlContext Descriptor - How a render session gets the OpenGL context that it renders with.
- Open
GlContext Provider Flag - An OpenGL context platform, as a bit in a set.
- Open
GlSurface Descriptor - An OpenGL surface to present to, for
MapHandle::attach_open_gl_surface(). - Open
GlSurface Replacement - A new OpenGL surface for
RenderSessionHandle::set_open_gl_surface_target(). - Open
GlTexture Frame - The OpenGL texture of an acquired frame.
- PanMomentum
- How a gesture’s pan keeps moving the map’s content after release.
- Premultiplied
Rgba8 Image - An image of 8-bit RGBA pixels whose colors are multiplied by their alpha.
- Projected
Meters - A point in the Web Mercator projection, in meters.
- Projection
Mode - A map’s whole projection mode.
- Projection
Mode Options - Settings that skew the map or draw it without perspective.
- Quaternion
- A rotation, as a quaternion.
- Queue
Lock - Your lock on a Vulkan queue that you and a render session both submit to.
- Release
Error - A consuming call that native refused, such as a release while a child handle is still live. It hands the handle back, so the caller can retry or drop it.
- Render
Abandon Result - The outcome of
RenderSessionHandle::abandon(). - Render
Backend Flag - A render backend, as a bit in a set.
- Render
Frame Result - How one frame demand finished.
- Render
Session Attach Options - Options for attaching a render session to a map.
- Render
Session Capabilities - What an attached render session supports.
- Render
Session Capability Flag - Something that a render session can do.
- Render
Session Handle - Owns one native handle.
- Render
Session Handle Discarding - Submits
RenderSessionHandlecommands without a completion. Each call returns the same acceptance status as its completing form, and native logs a command that later fails as a warning through the log handler. - Render
Session Snapshot - The state of a render session at one moment.
- Rendered
Feature - A feature that a rendered feature query found.
- Rendered
Feature Query Options - Options for a rendered feature query.
- Rendering
Stats - Statistics about the frames that a map renders.
- Resource
Kind Flag - A resource kind, as a bit in a set.
- Resource
Provider - A resource provider, for
RuntimeHandle::set_resource_provider(). - Resource
Range - The bytes from
starttoendof a resource, both included. - Resource
Request Cancel Handler - A cancel callback, for
ResourceRequestHandle::set_cancel_callback(). - Resource
Request Handle - Owns one native handle.
- Resource
Request Info - A request that a resource provider serves.
- Resource
Response - The answer to a resource request.
- Resource
Route - The requests that a resource provider serves.
- Resource
Transform - How to rewrite request URLs, for
RuntimeHandle::set_resource_transform(). - Resource
Transform Error - Why a resource transform fails a request.
- Resource
Transform Request Handle - Owns one native handle.
- Resource
Transform Rule - Query parameters to add to the URLs of requests that match a pattern.
- Retiring
Render Session - What a release of
RenderSessionHandleleaves while native retires the handle. Its functions stay callable until the handle retires, and fail withStatus::InvalidStateafterwards. It owns nothing, so dropping it changes nothing. - Runtime
Event - An event that a runtime or one of its maps raised.
- Runtime
Event Camera Change - The details of
RuntimeEventType::MapCameraWillChangeandRuntimeEventType::MapCameraDidChange. - Runtime
Event Flag - An event type, as a bit in a set.
- Runtime
Event Glyphs - The details of a glyph event.
- Runtime
Event Handler - An event callback, for
RuntimeHandle::set_event_handler(). - Runtime
Event Loading Failed - The details of
RuntimeEventType::MapLoadingFailed. - Runtime
Event Offline Region Response Error - The details of
RuntimeEventType::OfflineRegionResponseError. - Runtime
Event Offline Region Status - The details of
RuntimeEventType::OfflineRegionStatusChanged. - Runtime
Event Offline Region Tile Count Limit - The details of
RuntimeEventType::OfflineRegionTileCountLimitExceeded. - Runtime
Event Render Frame - The details of
RuntimeEventType::MapRenderFrameFinished. - Runtime
Event Source Changed - The details of
RuntimeEventType::MapSourceChanged. - Runtime
Event Sprite - The details of a sprite event.
- Runtime
Event Style Image - The details of
RuntimeEventType::MapStyleImageMissing. - Runtime
Event Tile Action - The details of
RuntimeEventType::MapTileAction. - Runtime
Handle - Owns one native handle.
- Runtime
Handle Discarding - Submits
RuntimeHandlecommands without a completion. Each call returns the same acceptance status as its completing form, and native logs a command that later fails as a warning through the log handler. - Runtime
Options - Options for
RuntimeHandle::create(). - Screen
Box - A rectangle of the screen, from its
mincorner to itsmaxcorner. - Screen
Line String - A line through points on the screen.
- Screen
Point - A point on the screen, in logical pixels from the map’s top-left corner.
- Source
Feature - A feature that a source feature query found.
- Source
Feature Query Options - Options for a source feature query.
- Style
Expression Handle - Owns one native handle.
- Style
Expression Info - What a style expression’s result depends on.
- Style
Expression Inputs - The inputs that a style expression reads while it evaluates.
- Style
Expression Options - Options for parsing a style expression.
- Style
Expression Type - The type of a style expression’s result.
- Style
Image Info - An image in the map’s style.
- Style
Image Options - Options for a style image, as the [sprite](https://maplibre.org/maplibre-style-spec/sprite/) spec describes them.
- Style
Layer Info - A layer in the map’s style.
- Style
Source Info - A source in the map’s style.
- Style
Source Tile Info - The tiles of a source, as the style lists them.
- Style
Transition Options - The default [transition](https://maplibre.org/maplibre-style-spec/transition/) for changes to a style’s paint properties.
- Texture
Image Info - The layout of the pixels that
RenderSessionHandle::read_texture()reads. - Texture
Readback Result - The pixels that
RenderSessionHandle::read_texture()reads. - TileId
- The ID of a tile.
- Unit
Bezier - A timing curve from (0, 0) to (1, 1), with the control points (
x1,y1) and (x2,y2). - UrlMatch
Flag - How a URL pattern matches a request’s URL.
- UrlQuery
Parameter - A query parameter that a resource transform rule adds to a URL.
- Vec3
- A vector in three dimensions.
- Vulkan
Borrowed Texture - A Vulkan image of a borrowed ring.
- Vulkan
Borrowed Texture Descriptor - A ring of your Vulkan images, for
MapHandle::attach_vulkan_borrowed_texture(). - Vulkan
Borrowed Texture Replacement - New Vulkan images for a borrowed ring, for
RenderSessionHandle::set_vulkan_borrowed_texture_target(). - Vulkan
Context Descriptor - The Vulkan device and queue that a render session uses.
- Vulkan
Device Context Result - A Vulkan device’s context, as
VulkanDeviceHandle::get_context()reports it. - Vulkan
Device Handle - Owns one native handle.
- Vulkan
Device Options - Options for
VulkanDeviceHandle::create(). - Vulkan
Surface Descriptor - A Vulkan surface to present to, for
MapHandle::attach_vulkan_surface(). - Vulkan
Surface Replacement - A new Vulkan surface for
RenderSessionHandle::set_vulkan_surface_target(). - Vulkan
Texture Frame - The Vulkan image of an acquired frame.
- Wake
- A callback that tells the caller when work is ready.
- Wayland
Surface Descriptor - A Wayland surface to present to, for
MapHandle::attach_wayland_surface(). - Wayland
Surface Replacement - A new Wayland surface for
RenderSessionHandle::set_wayland_surface_target(). - WebGl
Context Descriptor - The WebGL context or canvas that a render session uses.
- WebGpu
Borrowed Texture - A WebGPU texture of a borrowed ring.
- WebGpu
Borrowed Texture Descriptor - A ring of your WebGPU textures, for
MapHandle::attach_web_gpu_borrowed_texture(). - WebGpu
Borrowed Texture Replacement - New WebGPU textures for a borrowed ring, for
RenderSessionHandle::set_web_gpu_borrowed_texture_target(). - WebGpu
Context Descriptor - The WebGPU device that a render session uses.
- WebGpu
Surface Descriptor - A WebGPU surface to present to, for
MapHandle::attach_web_gpu_surface(). - WebGpu
Surface Replacement - A new WebGPU surface for
RenderSessionHandle::set_web_gpu_surface_target(). - WebGpu
Texture Frame - The WebGPU texture of an acquired frame.
- WglContext
Descriptor - The WGL objects that a render session makes its OpenGL context from.
- Win32
Window Descriptor - A Win32 window to present to, for
MapHandle::attach_win32_window(). - Win32
Window Replacement - A new Win32 window for
RenderSessionHandle::set_win32_window_target().
Enums§
- Cache
Database Operation - A maintenance action on a runtime’s cache database.
- Camera
Change Mode - Whether a camera change jumps or animates.
- Camera
Change Source - What moved the camera.
- Camera
Transition Outcome - How a camera change ended.
- Camera
Update Mode - How a camera command moves the camera.
- Constrain
Mode - How the map keeps the camera within the world or within its bounds.
- Error
- A failure that native or this binding reports.
- Feature
Id - The ID of a feature in a source, as the source’s data gives it.
- Gesture
Phase - Where a camera change falls in a gesture that the user makes.
- GpuSync
Kind - How one side waits for the other’s GPU work on a shared texture.
- LogEvent
- The part of the library that logged a message.
- LogSeverity
- The severity of a log message.
- MapLoad
Error - Why a map failed to load a style.
- MapMode
- When a map renders.
- Momentum
Decay Model - How a part of a gesture’s momentum slows from its release speed.
- Network
Status - Whether the library may use the network.
- North
Orientation - The screen direction that north points to when the bearing is 0.
- Offline
Region Definition - The area, zoom range, and style that an offline region covers.
- Offline
Region Download State - Whether an offline region is downloading.
- Open
GlClient Api - The OpenGL API that a context renders with.
- Open
GlContext Descriptor Data - The WGL, EGL, or WebGL part of an OpenGL context descriptor.
- Open
GlContext Ownership - Whether a render session’s OpenGL context shares objects with yours.
- Render
Abandon Disposition - What
RenderSessionHandle::abandon()did with a session’s graphics objects. - Render
Driver Kind - The thread that runs a render session’s graphics work.
- Render
Mode - Whether a frame drew the map complete, or lacked resources that are still loading.
- Render
Result - How a frame demand finished.
- Render
Session State - Where a render session is in its life.
- Rendered
Query Geometry - The screen area that a rendered feature query covers.
- Report
- A failure that the binding contained because no caller could receive it.
- Resource
Error Reason - Why a resource request failed.
- Resource
Kind - The kind of a resource that the library loads.
- Resource
Loading Method - Where a request may load its resource from.
- Resource
Priority - The priority of a resource request.
- Resource
Response Status - The outcome of a resource request.
- Resource
Storage Policy - Whether the library keeps a loaded resource in its cache.
- Resource
Usage - Whether a request loads a resource for a map or an offline region.
- Runtime
Event Payload - The details of an event, in the member that its
payload_typenames. - Runtime
Event Source Type - The kind of handle that raised an event.
- Runtime
Event Type - The kind of an event.
- Status
- The result of a call or of asynchronous work.
- Style
Expression Type Kind - The type of a style expression’s result, or of the items of an array result.
- Style
Image Text Fit - How an image stretches to fit text along one axis.
- Style
Layer Visibility - Whether a layer shows.
- Style
Raster DemEncoding - How a raster DEM tile encodes elevation in its colors.
- Style
Source Type - The type of a style source.
- Style
Tile Scheme - Whether a tileset counts tile rows from the north (XYZ) or the south (TMS).
- Style
Vector Tile Encoding - The format of vector tiles.
- Tile
LodMode - How the map picks the level of detail of its tiles.
- Tile
Operation - A step in loading a tile.
- Viewport
Mode - The vertical direction of the image that the map renders.
- Vulkan
Image Owner - The queue family that a borrowed image goes to after each frame.
- WebGl
Context Kind - How a render session gets its WebGL context.
Constants§
- DIAGNOSTIC_
MESSAGE_ CAPACITY - The size of a diagnostic message in bytes, with its terminator.
- FRAME_
DEMAND_ TOKEN_ STILL_ IMAGE - The token of the frame results that a session adds when it renders an image
for
MapHandle::request_still_image(). Your own demands can’t use it. - TEXTURE_
RING_ MAX_ DEPTH - The most textures that a render session’s texture ring can have.
- VULKAN_
NON_ DISPATCHABLE_ HANDLE_ NULL - The null Vulkan non-dispatchable handle.
Functions§
- c_
version - Returns the API epoch of the library.
- camera_
for_ tile - Computes the camera that shows exactly one tile on a square map.
- clear_
log_ callback - Sends log messages to the platform’s log again, instead of a callback.
- get_
network_ status - Reads whether the library may use the network.
- get_
plugin_ register_ function_ v1 - Returns the function that registers a plugin’s style layer types.
- lat_
lng_ for_ projected_ meters - Converts meters in the Web Mercator projection to a coordinate.
- logical_
extent_ physical_ size - Computes the size in pixels of a target with a logical size and scale factor.
- open_
gl_ supported_ context_ provider_ mask - Reports the OpenGL context platforms that this build of the library has.
- projected_
meters_ for_ lat_ lng - Converts a coordinate to meters in the Web Mercator projection.
- set_
log_ async_ severity_ mask - Selects the severities that the library logs on a background thread.
- set_
log_ callback - Sends the log messages of every runtime in the process to a callback.
- set_
network_ status - Tells the library whether it may use the network.
- set_
reporter - Installs the process-wide reporter, replacing any previous one, and returns whether one was installed. With no reporter, each report goes to standard error.
- supported_
render_ backend_ mask - Returns the render backends that this build of the library draws with.