maplibre_native_ffi/generated/runtime.rs
1// Generated from C headers by tools/bindgen. Do not edit.
2use super::*;
3
4native_owner! {
5 /// Owns one native handle.
6 ///
7 /// A runtime owns maps and the network and cache settings that they share.
8 ///
9 /// See `mln_runtime` in the
10 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/base_8h.html).
11 pub struct RuntimeHandle(mln_runtime) dispose |raw| crate::error::check(|out_diagnostic| unsafe { sys::mln_runtime_dispose(raw, out_diagnostic) });
12 /// Returns the native handle value, which runtime events report as their source.
13 fn id;
14}
15
16impl RuntimeHandle {
17 /// Stops sending the events of the runtime and its maps to a callback.
18 ///
19 /// See `mln_runtime_clear_event_handler` in the
20 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
21 pub fn clear_event_handler(&self) -> Result<NativeFuture<CommandCompletion>> {
22 let call = self.inner.call();
23 call.command(|runtime, completion, out_diagnostic| unsafe {
24 sys::mln_runtime_clear_event_handler(runtime, completion, out_diagnostic)
25 })
26 }
27
28 /// Stops adding headers to the runtime's HTTP requests.
29 ///
30 /// See `mln_runtime_clear_http_header_transform` in the
31 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
32 pub fn clear_http_header_transform(&self) -> Result<NativeFuture<CommandCompletion>> {
33 let call = self.inner.call();
34 call.command(|runtime, completion, out_diagnostic| unsafe {
35 sys::mln_runtime_clear_http_header_transform(runtime, completion, out_diagnostic)
36 })
37 }
38
39 /// Removes the runtime's resource provider, so the library loads every
40 /// request itself.
41 ///
42 /// See `mln_runtime_clear_resource_provider` in the
43 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
44 pub fn clear_resource_provider(&self) -> Result<NativeFuture<CommandCompletion>> {
45 let call = self.inner.call();
46 call.command(|runtime, completion, out_diagnostic| unsafe {
47 sys::mln_runtime_clear_resource_provider(runtime, completion, out_diagnostic)
48 })
49 }
50
51 /// Stops rewriting the URLs of the runtime's network requests.
52 ///
53 /// See `mln_runtime_clear_resource_transform` in the
54 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
55 pub fn clear_resource_transform(&self) -> Result<NativeFuture<CommandCompletion>> {
56 let call = self.inner.call();
57 call.command(|runtime, completion, out_diagnostic| unsafe {
58 sys::mln_runtime_clear_resource_transform(runtime, completion, out_diagnostic)
59 })
60 }
61
62 /// Creates a runtime.
63 ///
64 /// A runtime holds maps and the resource loading, cache, and offline
65 /// regions that they share. In a browser, create runtimes on a Web Worker,
66 /// not on the main thread.
67 ///
68 /// See `mln_runtime_create` in the
69 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
70 ///
71 /// # Errors
72 ///
73 /// - `Status::InvalidArgument` when the cache database file that `options`
74 /// names can't be opened or created.
75 pub fn create(options: Option<&RuntimeOptions<'_>>) -> Result<RuntimeHandle> {
76 let mut call = Call::global();
77 crate::abi::validate_abi_version()?;
78 let mut out_runtime = sys::mln_runtime(0);
79 let options = call.optional_reference(options.as_ref())?;
80 call.status(|_, out_diagnostic| unsafe {
81 sys::mln_runtime_create(options, &mut out_runtime, out_diagnostic)
82 })?;
83 Ok(RuntimeHandle::adopt(out_runtime)?)
84 }
85
86 /// Creates a map on `runtime`.
87 ///
88 /// Asynchronous calls on the map before the completion runs wait for it,
89 /// and complete with `Status::InvalidState` when creation fails.
90 ///
91 /// See `mln_runtime_create_map` in the
92 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
93 pub fn create_map(&self, options: &MapOptions) -> Result<(MapHandle, NativeFuture<()>)> {
94 let mut call = self.inner.call();
95 let mut out_map = sys::mln_map(0);
96 let options = call.reference(&options)?;
97 let future = call.complete(
98 |runtime, completion, out_diagnostic| unsafe {
99 sys::mln_runtime_create_map(
100 runtime,
101 options,
102 &mut out_map,
103 completion,
104 out_diagnostic,
105 )
106 },
107 completion::unit,
108 )?;
109 Ok((MapHandle::adopt(out_map)?, future))
110 }
111
112 /// Creates an offline region in the runtime's cache file.
113 ///
114 /// `metadata` holds any bytes to store with the region, such as its name.
115 /// The region doesn't download until
116 /// `RuntimeHandle::set_offline_region_download_state()` makes its download
117 /// active.
118 ///
119 /// See `mln_runtime_create_offline_region` in the
120 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
121 pub fn create_offline_region(
122 &self,
123 definition: &OfflineRegionDefinition,
124 metadata: &[u8],
125 ) -> Result<NativeFuture<OfflineRegionInfo>> {
126 let mut call = self.inner.call();
127 let metadata_size = convert::count(metadata.len())?;
128 let definition = call.reference(&definition)?;
129 let metadata = metadata.as_ptr().cast();
130 call.complete(
131 |runtime, completion, out_diagnostic| unsafe {
132 sys::mln_runtime_create_offline_region(
133 runtime,
134 definition,
135 metadata,
136 metadata_size,
137 completion,
138 out_diagnostic,
139 )
140 },
141 completion::value::<sys::mln_offline_region_info, _>,
142 )
143 }
144
145 /// Deletes the offline region `region_id` from the runtime's cache file.
146 ///
147 /// See `mln_runtime_delete_offline_region` in the
148 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
149 ///
150 /// # Errors
151 ///
152 /// - `Status::NotFound` when the cache file has no region `region_id`.
153 pub fn delete_offline_region(&self, region_id: i64) -> Result<NativeFuture<()>> {
154 let call = self.inner.call();
155 call.complete(
156 |runtime, completion, out_diagnostic| unsafe {
157 sys::mln_runtime_delete_offline_region(
158 runtime,
159 region_id,
160 completion,
161 out_diagnostic,
162 )
163 },
164 completion::unit,
165 )
166 }
167
168 /// Releases a runtime in any state, without waiting.
169 ///
170 /// The runtime finishes its teardown after its maps are released.
171 ///
172 /// See `mln_runtime_dispose` in the
173 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
174 pub fn dispose(self) -> std::result::Result<(), ReleaseError<Self>> {
175 self.consume(|runtime| {
176 let mut call = Call::new(runtime);
177 call.status(|runtime, out_diagnostic| unsafe {
178 sys::mln_runtime_dispose(runtime, out_diagnostic)
179 })
180 })
181 }
182
183 /// Reads the offline region `region_id`.
184 ///
185 /// The result is null when the cache file has no region with that ID.
186 ///
187 /// See `mln_runtime_get_offline_region` in the
188 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
189 pub fn get_offline_region(
190 &self,
191 region_id: i64,
192 ) -> Result<NativeFuture<Option<OfflineRegionInfo>>> {
193 let call = self.inner.call();
194 call.complete(
195 |runtime, completion, out_diagnostic| unsafe {
196 sys::mln_runtime_get_offline_region(runtime, region_id, completion, out_diagnostic)
197 },
198 completion::optional::<sys::mln_offline_region_info, _>,
199 )
200 }
201
202 /// Reads the download progress of the offline region `region_id`.
203 ///
204 /// While the download is active, the counts cover what it has visited. Once
205 /// it's inactive, they cover every resource the region holds, including
206 /// those that only earlier versions of its style listed, so the completed
207 /// counts can exceed the required counts.
208 ///
209 /// See `mln_runtime_get_offline_region_status` in the
210 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
211 ///
212 /// # Errors
213 ///
214 /// - `Status::NotFound` when the cache file has no region `region_id`.
215 pub fn get_offline_region_status(
216 &self,
217 region_id: i64,
218 ) -> Result<NativeFuture<OfflineRegionStatus>> {
219 let call = self.inner.call();
220 call.complete(
221 |runtime, completion, out_diagnostic| unsafe {
222 sys::mln_runtime_get_offline_region_status(
223 runtime,
224 region_id,
225 completion,
226 out_diagnostic,
227 )
228 },
229 completion::value::<sys::mln_offline_region_status, _>,
230 )
231 }
232
233 /// Makes maps check each resource of the offline region `region_id` with
234 /// the server before they use it.
235 ///
236 /// The region keeps its resources. Starting its download again fetches the
237 /// invalidated resources for offline use. If the style or a TileJSON
238 /// document is then missing or invalid, the download reports an offline
239 /// region response error and goes on from the stored copy. Resources that
240 /// the current style no longer lists stay in the region until it's deleted.
241 ///
242 /// See `mln_runtime_invalidate_offline_region` in the
243 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
244 ///
245 /// # Errors
246 ///
247 /// - `Status::NotFound` when the cache file has no region `region_id`.
248 pub fn invalidate_offline_region(&self, region_id: i64) -> Result<NativeFuture<()>> {
249 let call = self.inner.call();
250 call.complete(
251 |runtime, completion, out_diagnostic| unsafe {
252 sys::mln_runtime_invalidate_offline_region(
253 runtime,
254 region_id,
255 completion,
256 out_diagnostic,
257 )
258 },
259 completion::unit,
260 )
261 }
262
263 /// Lists the offline regions in the runtime's cache file.
264 ///
265 /// See `mln_runtime_list_offline_regions` in the
266 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
267 pub fn list_offline_regions(&self) -> Result<NativeFuture<Vec<OfflineRegionInfo>>> {
268 let call = self.inner.call();
269 call.complete(
270 |runtime, completion, out_diagnostic| unsafe {
271 sys::mln_runtime_list_offline_regions(runtime, completion, out_diagnostic)
272 },
273 completion::list::<sys::mln_offline_region_info, _>,
274 )
275 }
276
277 /// Copies the offline regions of another cache file into the runtime's
278 /// cache file.
279 ///
280 /// A region whose definition and metadata match one that the runtime's file
281 /// already has isn't copied again. The result lists the runtime's copy of
282 /// each region in the other file.
283 ///
284 /// See `mln_runtime_merge_offline_regions` in the
285 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
286 ///
287 /// # Errors
288 ///
289 /// - `Status::InvalidArgument` when `side_database_path` isn't a readable
290 /// database file.
291 /// - `Status::NativeError` when the merge would exceed the tile limit that
292 /// `RuntimeEventType::OfflineRegionTileCountLimitExceeded` describes.
293 pub fn merge_offline_regions(
294 &self,
295 side_database_path: &str,
296 ) -> Result<NativeFuture<Vec<OfflineRegionInfo>>> {
297 let mut call = self.inner.call();
298 let side_database_path = call.input(&side_database_path)?;
299 call.complete(
300 |runtime, completion, out_diagnostic| unsafe {
301 sys::mln_runtime_merge_offline_regions(
302 runtime,
303 side_database_path,
304 completion,
305 out_diagnostic,
306 )
307 },
308 completion::list::<sys::mln_offline_region_info, _>,
309 )
310 }
311
312 /// Releases a runtime.
313 ///
314 /// Release the runtime's maps first.
315 ///
316 /// See `mln_runtime_release` in the
317 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
318 pub fn release(self) -> std::result::Result<NativeFuture<()>, ReleaseError<Self>> {
319 self.consume(|runtime| {
320 let call = Call::new(runtime);
321 call.complete(
322 |runtime, completion, out_diagnostic| unsafe {
323 sys::mln_runtime_release(runtime, completion, out_diagnostic)
324 },
325 completion::unit,
326 )
327 })
328 }
329
330 /// Runs a maintenance action on the runtime's cache database.
331 ///
332 /// See `mln_runtime_run_cache_database_operation` in the
333 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
334 pub fn run_cache_database_operation(
335 &self,
336 operation: CacheDatabaseOperation,
337 ) -> Result<NativeFuture<()>> {
338 let call = self.inner.call();
339 call.complete(
340 |runtime, completion, out_diagnostic| unsafe {
341 sys::mln_runtime_run_cache_database_operation(
342 runtime,
343 operation.as_raw(),
344 completion,
345 out_diagnostic,
346 )
347 },
348 completion::unit,
349 )
350 }
351
352 /// Sends the events of the runtime and its maps to a callback.
353 ///
354 /// The callback replaces the one set before.
355 ///
356 /// See `mln_runtime_set_event_handler` in the
357 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
358 pub fn set_event_handler(
359 &self,
360 handler: RuntimeEventHandler,
361 ) -> Result<NativeFuture<CommandCompletion>> {
362 let mut call = self.inner.call();
363 let handler = call.reference(&handler)?;
364 call.command(|runtime, completion, out_diagnostic| unsafe {
365 sys::mln_runtime_set_event_handler(runtime, handler, completion, out_diagnostic)
366 })
367 }
368
369 /// Adds headers to the runtime's HTTP requests.
370 ///
371 /// The transform replaces the one set before. In a browser or on
372 /// OpenHarmony, serve the requests with
373 /// `RuntimeHandle::set_resource_provider()` instead.
374 ///
375 /// Runs on a library thread.
376 ///
377 /// See `mln_runtime_set_http_header_transform` in the
378 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
379 ///
380 /// # Errors
381 ///
382 /// - `Status::Unsupported` when the library runs in a browser or on
383 /// OpenHarmony.
384 pub fn set_http_header_transform(
385 &self,
386 transform: HttpHeaderTransform,
387 ) -> Result<NativeFuture<CommandCompletion>> {
388 let mut call = self.inner.call();
389 let transform = call.reference(&transform)?;
390 call.command(|runtime, completion, out_diagnostic| unsafe {
391 sys::mln_runtime_set_http_header_transform(
392 runtime,
393 transform,
394 completion,
395 out_diagnostic,
396 )
397 })
398 }
399
400 /// Limits the size of the runtime's ambient cache.
401 ///
402 /// `size` is in bytes. Offline regions don't count toward it. It defaults
403 /// to 50 MB, or to 0 in the browser when the runtime has no cache file.
404 ///
405 /// See `mln_runtime_set_maximum_ambient_cache_size` in the
406 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
407 pub fn set_maximum_ambient_cache_size(&self, size: u64) -> Result<NativeFuture<()>> {
408 let call = self.inner.call();
409 call.complete(
410 |runtime, completion, out_diagnostic| unsafe {
411 sys::mln_runtime_set_maximum_ambient_cache_size(
412 runtime,
413 size,
414 completion,
415 out_diagnostic,
416 )
417 },
418 completion::unit,
419 )
420 }
421
422 /// Starts or pauses the download of the offline region `region_id`.
423 ///
424 /// Setting the state that the download already has does nothing. A download
425 /// stops when the runtime closes.
426 ///
427 /// See `mln_runtime_set_offline_region_download_state` in the
428 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
429 ///
430 /// # Errors
431 ///
432 /// - `Status::NotFound` when the cache file has no region `region_id`.
433 pub fn set_offline_region_download_state(
434 &self,
435 region_id: i64,
436 state: OfflineRegionDownloadState,
437 ) -> Result<NativeFuture<()>> {
438 let call = self.inner.call();
439 call.complete(
440 |runtime, completion, out_diagnostic| unsafe {
441 sys::mln_runtime_set_offline_region_download_state(
442 runtime,
443 region_id,
444 state.as_raw(),
445 completion,
446 out_diagnostic,
447 )
448 },
449 completion::unit,
450 )
451 }
452
453 /// Selects the events that the runtime reports about the download of the
454 /// offline region `region_id`.
455 ///
456 /// `events` holds bits of `RuntimeEventFlag::ALL_RUNTIME_EVENTS` and
457 /// replaces the region's previous selection.
458 ///
459 /// See `mln_runtime_set_offline_region_observed` in the
460 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
461 ///
462 /// # Errors
463 ///
464 /// - `Status::NotFound` when the cache file has no region `region_id`.
465 pub fn set_offline_region_observed(
466 &self,
467 region_id: i64,
468 events: RuntimeEventFlag,
469 ) -> Result<NativeFuture<()>> {
470 let call = self.inner.call();
471 call.complete(
472 |runtime, completion, out_diagnostic| unsafe {
473 sys::mln_runtime_set_offline_region_observed(
474 runtime,
475 region_id,
476 events.bits(),
477 completion,
478 out_diagnostic,
479 )
480 },
481 completion::unit,
482 )
483 }
484
485 /// Serves the runtime's network requests through a callback.
486 ///
487 /// The provider receives the network requests that its routes match, and
488 /// the library loads the rest as usual. A provider can serve URL schemes
489 /// that the library can't load itself. The provider replaces the one set
490 /// before.
491 ///
492 /// See `mln_runtime_set_resource_provider` in the
493 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
494 pub fn set_resource_provider(
495 &self,
496 provider: ResourceProvider,
497 ) -> Result<NativeFuture<CommandCompletion>> {
498 let mut call = self.inner.call();
499 let provider = call.reference(&provider)?;
500 call.command(|runtime, completion, out_diagnostic| unsafe {
501 sys::mln_runtime_set_resource_provider(runtime, provider, completion, out_diagnostic)
502 })
503 }
504
505 /// Rewrites the URLs of the runtime's network requests.
506 ///
507 /// The transform replaces the one set before.
508 ///
509 /// See `mln_runtime_set_resource_transform` in the
510 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
511 pub fn set_resource_transform(
512 &self,
513 transform: ResourceTransform,
514 ) -> Result<NativeFuture<CommandCompletion>> {
515 let mut call = self.inner.call();
516 let transform = call.reference(&transform)?;
517 call.command(|runtime, completion, out_diagnostic| unsafe {
518 sys::mln_runtime_set_resource_transform(runtime, transform, completion, out_diagnostic)
519 })
520 }
521
522 /// Replaces the metadata of the offline region `region_id`.
523 ///
524 /// See `mln_runtime_update_offline_region_metadata` in the
525 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/map_8h.html).
526 ///
527 /// # Errors
528 ///
529 /// - `Status::NotFound` when the cache file has no region `region_id`.
530 pub fn update_offline_region_metadata(
531 &self,
532 region_id: i64,
533 metadata: &[u8],
534 ) -> Result<NativeFuture<OfflineRegionInfo>> {
535 let call = self.inner.call();
536 let metadata_size = convert::count(metadata.len())?;
537 let metadata = metadata.as_ptr().cast();
538 call.complete(
539 |runtime, completion, out_diagnostic| unsafe {
540 sys::mln_runtime_update_offline_region_metadata(
541 runtime,
542 region_id,
543 metadata,
544 metadata_size,
545 completion,
546 out_diagnostic,
547 )
548 },
549 completion::value::<sys::mln_offline_region_info, _>,
550 )
551 }
552}
553
554/// Submits [`RuntimeHandle`] commands without a completion. Each call returns
555/// the same acceptance status as its completing form, and native logs a
556/// command that later fails as a warning through the log handler.
557pub struct RuntimeHandleDiscarding<'a>(&'a RuntimeHandle);
558impl RuntimeHandle {
559 pub fn discarding(&self) -> RuntimeHandleDiscarding<'_> {
560 RuntimeHandleDiscarding(self)
561 }
562}
563impl RuntimeHandleDiscarding<'_> {
564 /// Stops sending the events of the runtime and its maps to a callback.
565 ///
566 /// See `mln_runtime_clear_event_handler` in the
567 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
568 pub fn clear_event_handler(&self) -> Result<()> {
569 let call = self.0.inner.call();
570 call.discard(|runtime, completion, out_diagnostic| unsafe {
571 sys::mln_runtime_clear_event_handler(runtime, completion, out_diagnostic)
572 })
573 }
574
575 /// Stops adding headers to the runtime's HTTP requests.
576 ///
577 /// See `mln_runtime_clear_http_header_transform` in the
578 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
579 pub fn clear_http_header_transform(&self) -> Result<()> {
580 let call = self.0.inner.call();
581 call.discard(|runtime, completion, out_diagnostic| unsafe {
582 sys::mln_runtime_clear_http_header_transform(runtime, completion, out_diagnostic)
583 })
584 }
585
586 /// Removes the runtime's resource provider, so the library loads every
587 /// request itself.
588 ///
589 /// See `mln_runtime_clear_resource_provider` in the
590 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
591 pub fn clear_resource_provider(&self) -> Result<()> {
592 let call = self.0.inner.call();
593 call.discard(|runtime, completion, out_diagnostic| unsafe {
594 sys::mln_runtime_clear_resource_provider(runtime, completion, out_diagnostic)
595 })
596 }
597
598 /// Stops rewriting the URLs of the runtime's network requests.
599 ///
600 /// See `mln_runtime_clear_resource_transform` in the
601 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
602 pub fn clear_resource_transform(&self) -> Result<()> {
603 let call = self.0.inner.call();
604 call.discard(|runtime, completion, out_diagnostic| unsafe {
605 sys::mln_runtime_clear_resource_transform(runtime, completion, out_diagnostic)
606 })
607 }
608
609 /// Sends the events of the runtime and its maps to a callback.
610 ///
611 /// The callback replaces the one set before.
612 ///
613 /// See `mln_runtime_set_event_handler` in the
614 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
615 pub fn set_event_handler(&self, handler: RuntimeEventHandler) -> Result<()> {
616 let mut call = self.0.inner.call();
617 let handler = call.reference(&handler)?;
618 call.discard(|runtime, completion, out_diagnostic| unsafe {
619 sys::mln_runtime_set_event_handler(runtime, handler, completion, out_diagnostic)
620 })
621 }
622
623 /// Adds headers to the runtime's HTTP requests.
624 ///
625 /// The transform replaces the one set before. In a browser or on
626 /// OpenHarmony, serve the requests with
627 /// `RuntimeHandle::set_resource_provider()` instead.
628 ///
629 /// Runs on a library thread.
630 ///
631 /// See `mln_runtime_set_http_header_transform` in the
632 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
633 ///
634 /// # Errors
635 ///
636 /// - `Status::Unsupported` when the library runs in a browser or on
637 /// OpenHarmony.
638 pub fn set_http_header_transform(&self, transform: HttpHeaderTransform) -> Result<()> {
639 let mut call = self.0.inner.call();
640 let transform = call.reference(&transform)?;
641 call.discard(|runtime, completion, out_diagnostic| unsafe {
642 sys::mln_runtime_set_http_header_transform(
643 runtime,
644 transform,
645 completion,
646 out_diagnostic,
647 )
648 })
649 }
650
651 /// Serves the runtime's network requests through a callback.
652 ///
653 /// The provider receives the network requests that its routes match, and
654 /// the library loads the rest as usual. A provider can serve URL schemes
655 /// that the library can't load itself. The provider replaces the one set
656 /// before.
657 ///
658 /// See `mln_runtime_set_resource_provider` in the
659 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
660 pub fn set_resource_provider(&self, provider: ResourceProvider) -> Result<()> {
661 let mut call = self.0.inner.call();
662 let provider = call.reference(&provider)?;
663 call.discard(|runtime, completion, out_diagnostic| unsafe {
664 sys::mln_runtime_set_resource_provider(runtime, provider, completion, out_diagnostic)
665 })
666 }
667
668 /// Rewrites the URLs of the runtime's network requests.
669 ///
670 /// The transform replaces the one set before.
671 ///
672 /// See `mln_runtime_set_resource_transform` in the
673 /// [C API reference](https://maplibre.org/maplibre-native-ffi/reference/c/runtime_8h.html).
674 pub fn set_resource_transform(&self, transform: ResourceTransform) -> Result<()> {
675 let mut call = self.0.inner.call();
676 let transform = call.reference(&transform)?;
677 call.discard(|runtime, completion, out_diagnostic| unsafe {
678 sys::mln_runtime_set_resource_transform(runtime, transform, completion, out_diagnostic)
679 })
680 }
681}