mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
38 lines
17 KiB
HTML
38 lines
17 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="APCs define an interface for performing work asynchronously. This work can be implemented through procedures which can be called asynchronously, hence the name AsyncProcedureCall or APC for short."><meta name="keywords" content="rust, rustlang, rust-lang, AsyncProcedureCall"><title>AsyncProcedureCall in maplibre::io::apc - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../../normalize.css"><link rel="stylesheet" href="../../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../../ayu.css" disabled><link rel="stylesheet" href="../../../dark.css" disabled><link rel="stylesheet" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../../main.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../../maplibre/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../../maplibre/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">AsyncProcedureCall</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Context">Context</a></li><li><a href="#associatedtype.Transferables">Transferables</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.call">call</a></li><li><a href="#tymethod.receive">receive</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In maplibre::io::apc</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../maplibre/index.html"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../../index.html">maplibre</a>::<wbr><a href="../index.html">io</a>::<wbr><a href="index.html">apc</a>::<wbr><a class="trait" href="#">AsyncProcedureCall</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../../src/maplibre/io/apc.rs.html#130-141">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait AsyncProcedureCall<HC: <a class="trait" href="../source_client/trait.HttpClient.html" title="trait maplibre::io::source_client::HttpClient">HttpClient</a>>: 'static {
|
||
type <a href="#associatedtype.Context" class="associatedtype">Context</a>: <a class="trait" href="trait.Context.html" title="trait maplibre::io::apc::Context">Context</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Transferables" title="type maplibre::io::apc::AsyncProcedureCall::Transferables">Transferables</a>, HC> + <a class="trait" href="https://doc.rust-lang.org/1.65.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>;
|
||
type <a href="#associatedtype.Transferables" class="associatedtype">Transferables</a>: <a class="trait" href="../transferables/trait.Transferables.html" title="trait maplibre::io::transferables::Transferables">Transferables</a>;
|
||
|
||
fn <a href="#tymethod.receive" class="fnname">receive</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.65.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="enum.Message.html" title="enum maplibre::io::apc::Message">Message</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Transferables" title="type maplibre::io::apc::AsyncProcedureCall::Transferables">Transferables</a>>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.call" class="fnname">call</a>(<br> &self,<br> input: <a class="enum" href="enum.Input.html" title="enum maplibre::io::apc::Input">Input</a>,<br> procedure: <a class="type" href="type.AsyncProcedure.html" title="type maplibre::io::apc::AsyncProcedure">AsyncProcedure</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Context" title="type maplibre::io::apc::AsyncProcedureCall::Context">Context</a>><br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.65.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.65.0/std/primitive.unit.html">()</a>, <a class="enum" href="enum.CallError.html" title="enum maplibre::io::apc::CallError">CallError</a>>;
|
||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>APCs define an interface for performing work asynchronously.
|
||
This work can be implemented through procedures which can be called asynchronously, hence the
|
||
name AsyncProcedureCall or APC for short.</p>
|
||
<p>APCs serve as an abstraction for doing work on a separate thread, and then getting responses
|
||
back. An asynchronous procedure call can for example be performed by using message passing. In
|
||
fact this could theoretically work over a network socket.</p>
|
||
<p>It is possible to schedule work on a remote host by calling <a href="trait.AsyncProcedureCall.html#tymethod.call" title="AsyncProcedureCall::call()"><code>AsyncProcedureCall::call()</code></a>
|
||
and getting the results back by calling the non-blocking function
|
||
<a href="trait.AsyncProcedureCall.html#tymethod.receive" title="AsyncProcedureCall::receive()"><code>AsyncProcedureCall::receive()</code></a>. The <a href="trait.AsyncProcedureCall.html#tymethod.receive" title="AsyncProcedureCall::receive()"><code>AsyncProcedureCall::receive()</code></a> function returns a
|
||
struct which implements <a href="../transferables/trait.Transferables.html" title="Transferables"><code>Transferables</code></a>.</p>
|
||
<h3 id="transferables"><a href="#transferables">Transferables</a></h3>
|
||
<p>Based on whether the current platform supports shared-memory or not, the implementation of APCs
|
||
might want to send the whole data from the worker to the caller back or just pointers to that
|
||
data. The <a href="../transferables/trait.Transferables.html" title="Transferables"><code>Transferables</code></a> trait allows developers to define that and use different data
|
||
layouts for different platforms.</p>
|
||
<h3 id="message-passing-vs-apc"><a href="#message-passing-vs-apc">Message Passing vs APC</a></h3>
|
||
<p>One might wonder why this is called <a href="trait.AsyncProcedureCall.html" title="AsyncProcedureCall"><code>AsyncProcedureCall</code></a> instead of <code>MessagePassingInterface</code>.
|
||
The reason for this is quite simple. We are actually referencing and calling procedures which
|
||
are defined in different threads, processes or hosts. That means, that an <a href="trait.AsyncProcedureCall.html" title="AsyncProcedureCall"><code>AsyncProcedureCall</code></a>
|
||
is actually distinct from a <code>MessagePassingInterface</code>.</p>
|
||
<h3 id="current-implementations"><a href="#current-implementations">Current Implementations</a></h3>
|
||
<p>We currently have two implementation for APCs. One uses the Tokio async runtime on native
|
||
targets in <a href="struct.SchedulerAsyncProcedureCall.html" title="SchedulerAsyncProcedureCall"><code>SchedulerAsyncProcedureCall</code></a>.
|
||
For the web we implemented an alternative way to call APCs which is called
|
||
[<code>PassingAsyncProcedureCall</code>]. This implementation does not depend on shared-memory compared to
|
||
<a href="struct.SchedulerAsyncProcedureCall.html" title="SchedulerAsyncProcedureCall"><code>SchedulerAsyncProcedureCall</code></a>. In fact, on the web we are currently not depending on
|
||
shared-memory because that feature is hidden behind feature flags in browsers
|
||
(see <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer">here</a>.</p>
|
||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><div id="associatedtype.Context" class="method has-srclink"><a class="srclink rightside" href="../../../src/maplibre/io/apc.rs.html#131">source</a><h4 class="code-header">type <a href="#associatedtype.Context" class="associatedtype">Context</a>: <a class="trait" href="trait.Context.html" title="trait maplibre::io::apc::Context">Context</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Transferables" title="type maplibre::io::apc::AsyncProcedureCall::Transferables">Transferables</a>, HC> + <a class="trait" href="https://doc.rust-lang.org/1.65.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a></h4></div><div id="associatedtype.Transferables" class="method has-srclink"><a class="srclink rightside" href="../../../src/maplibre/io/apc.rs.html#132">source</a><h4 class="code-header">type <a href="#associatedtype.Transferables" class="associatedtype">Transferables</a>: <a class="trait" href="../transferables/trait.Transferables.html" title="trait maplibre::io::transferables::Transferables">Transferables</a></h4></div></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.receive" class="method has-srclink"><a class="srclink rightside" href="../../../src/maplibre/io/apc.rs.html#135">source</a><h4 class="code-header">fn <a href="#tymethod.receive" class="fnname">receive</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.65.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="enum.Message.html" title="enum maplibre::io::apc::Message">Message</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Transferables" title="type maplibre::io::apc::AsyncProcedureCall::Transferables">Transferables</a>>></h4></div></summary><div class="docblock"><p>Try to receive a message non-blocking.</p>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.call" class="method has-srclink"><a class="srclink rightside" href="../../../src/maplibre/io/apc.rs.html#139-140">source</a><h4 class="code-header">fn <a href="#tymethod.call" class="fnname">call</a>(<br> &self,<br> input: <a class="enum" href="enum.Input.html" title="enum maplibre::io::apc::Input">Input</a>,<br> procedure: <a class="type" href="type.AsyncProcedure.html" title="type maplibre::io::apc::AsyncProcedure">AsyncProcedure</a><Self::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Context" title="type maplibre::io::apc::AsyncProcedureCall::Context">Context</a>><br>) -> <a class="enum" href="https://doc.rust-lang.org/1.65.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.65.0/std/primitive.unit.html">()</a>, <a class="enum" href="enum.CallError.html" title="enum maplibre::io::apc::CallError">CallError</a>></h4></div></summary><div class="docblock"><p>Call an <a href="type.AsyncProcedure.html" title="AsyncProcedure"><code>AsyncProcedure</code></a> using some <a href="enum.Input.html" title="Input"><code>Input</code></a>. This function is non-blocking and
|
||
returns immediately.</p>
|
||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-AsyncProcedureCall%3CHC%3E-for-SchedulerAsyncProcedureCall%3CHC%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../../../src/maplibre/io/apc.rs.html#178-209">source</a><a href="#impl-AsyncProcedureCall%3CHC%3E-for-SchedulerAsyncProcedureCall%3CHC%2C%20S%3E" class="anchor"></a><h3 class="code-header in-band">impl<HC: <a class="trait" href="../source_client/trait.HttpClient.html" title="trait maplibre::io::source_client::HttpClient">HttpClient</a>, S: <a class="trait" href="../scheduler/trait.Scheduler.html" title="trait maplibre::io::scheduler::Scheduler">Scheduler</a>> <a class="trait" href="trait.AsyncProcedureCall.html" title="trait maplibre::io::apc::AsyncProcedureCall">AsyncProcedureCall</a><HC> for <a class="struct" href="struct.SchedulerAsyncProcedureCall.html" title="struct maplibre::io::apc::SchedulerAsyncProcedureCall">SchedulerAsyncProcedureCall</a><HC, S></h3></section></summary><div class="impl-items"><section id="associatedtype.Context-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Context-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Context" class="associatedtype">Context</a> = <a class="struct" href="struct.SchedulerContext.html" title="struct maplibre::io::apc::SchedulerContext">SchedulerContext</a><<<a class="struct" href="struct.SchedulerAsyncProcedureCall.html" title="struct maplibre::io::apc::SchedulerAsyncProcedureCall">SchedulerAsyncProcedureCall</a><HC, S> as <a class="trait" href="trait.AsyncProcedureCall.html" title="trait maplibre::io::apc::AsyncProcedureCall">AsyncProcedureCall</a><HC>>::<a class="associatedtype" href="trait.AsyncProcedureCall.html#associatedtype.Transferables" title="type maplibre::io::apc::AsyncProcedureCall::Transferables">Transferables</a>, HC></h4></section><section id="associatedtype.Transferables-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Transferables-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Transferables" class="associatedtype">Transferables</a> = <a class="struct" href="../transferables/struct.DefaultTransferables.html" title="struct maplibre::io::transferables::DefaultTransferables">DefaultTransferables</a></h4></section></div></details></div><script src="../../../implementors/maplibre/io/apc/trait.AsyncProcedureCall.js" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="maplibre" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.65.0 (897e37553 2022-11-02)" ></div></body></html> |