Skip to content

Commit

Permalink
Deployed 33a24e6 to next with MkDocs 1.6.0 and mike 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
uniffi-docs[bot] committed Aug 7, 2024
1 parent fe3b142 commit a6b06e0
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 12 deletions.
24 changes: 24 additions & 0 deletions next/futures.html
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,15 @@
</ul>
</nav>

</li>

<li class="md-nav__item">
<a href="#cancelling-async-code" class="md-nav__link">
<span class="md-ellipsis">
Cancelling async code.
</span>
</a>

</li>

</ul>
Expand Down Expand Up @@ -1459,6 +1468,15 @@
</ul>
</nav>

</li>

<li class="md-nav__item">
<a href="#cancelling-async-code" class="md-nav__link">
<span class="md-ellipsis">
Cancelling async code.
</span>
</a>

</li>

</ul>
Expand Down Expand Up @@ -1549,6 +1567,12 @@ <h3 id="python-uniffi_set_event_loop">Python: <code>uniffi_set_event_loop()</cod
Use <code>uniffi_set_event_loop()</code> to handle this case.
It should be called before the Rust code makes the async call and passed an eventloop to use.</p>
<p>Note that <code>uniffi_set_event_loop</code> cannot be glob-imported because it's not part of the library's <code>__all__</code>.</p>
<h2 id="cancelling-async-code">Cancelling async code.</h2>
<p>We don't directly support cancellation in UniFFI even when the underlying platforms do.
You should build your cancellation in a separate, library specific channel; for example, exposing a <code>cancel()</code> method that sets a flag that the library checks periodically.</p>
<p>Cancellation can then be exposed in the API and be mapped to one of the error variants, or None/empty-vec/whatever makes sense.
There's no builtin way to cancel a future, nor to cause/raise a platform native async cancellation error (eg, a swift <code>CancellationError</code>).</p>
<p>See also https://github.com/mozilla/uniffi-rs/pull/1768.</p>



Expand Down
13 changes: 6 additions & 7 deletions next/tutorial/foreign_language_bindings.html
Original file line number Diff line number Diff line change
Expand Up @@ -1534,9 +1534,9 @@ <h1 id="foreign-language-bindings">Foreign-language bindings</h1>
<p>The next step is to have UniFFI generate source code for your foreign language. It doesn't help you build this code, it just generates it for you.</p>
<h2 id="creating-the-bindgen-binary">Creating the bindgen binary</h2>
<p>First, make sure you have installed all the <a href="Prerequisites.html">prerequisites</a>.</p>
<p>Ideally you would then run the <code>uniffi-bindgen</code> binary from the <code>uniffi</code> crate to generate your bindings. However, this
is only available with <a href="https://doc.rust-lang.org/cargo/reference/unstable.html#artifact-dependencies">Cargo nightly</a>.
To work around this, you need to create a binary in your project that does the same thing.</p>
<p>Ideally you would then run the <code>uniffi-bindgen</code> binary from the <code>uniffi</code> crate to generate your bindings,
but if not on <a href="https://doc.rust-lang.org/cargo/reference/unstable.html#artifact-dependencies">Cargo nightly</a>,
you need to create a binary in your project that does the same thing.</p>
<p>Add the following to your <code>Cargo.toml</code>:</p>
<div class="highlight"><pre><span></span><code><span class="k">[[bin]]</span>
<span class="c1"># This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen.</span>
Expand All @@ -1550,11 +1550,10 @@ <h2 id="creating-the-bindgen-binary">Creating the bindgen binary</h2>
</code></pre></div></p>
<p>You can now run <code>uniffi-bindgen</code> from your project using <code>cargo run --features=uniffi/cli --bin uniffi-bindgen [args]</code></p>
<h3 id="multi-crate-workspaces">Multi-crate workspaces</h3>
<p>If your project consists of multiple crates in a Cargo workspace, then the process outlined above would require you
creating a binary for each crate that uses UniFFI. You can avoid this by creating a separate crate for running <code>uniffi-bindgen</code>:
- Name the crate <code>uniffi-bindgen</code>
<p>In a multiple crates workspace, you can create a separate crate for running <code>uniffi-bindgen</code>:
- Name the crate <code>uniffi-bindgen</code>, add it to your workspace.
- Add this dependency to <code>Cargo.toml</code>: <code>uniffi = {version = "0.XX.0", features = ["cli"] }</code>
- Follow the steps from the previous section to add the <code>uniffi-bindgen</code> binary target</p>
- As above, add the <code>uniffi-bindgen</code> binary target</p>
<p>Then your can run <code>uniffi-bindgen</code> from any crate in your project using <code>cargo run -p uniffi-bindgen [args]</code></p>
<h2 id="running-uniffi-bindgen-using-a-library-file">Running uniffi-bindgen using a library file</h2>
<p>Use <code>generate --library</code> to generate foreign bindings by using a cdylib file built for your library.
Expand Down
10 changes: 5 additions & 5 deletions next/udl/ext_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -1459,14 +1459,14 @@ <h2 id="types-from-procmacros-in-this-crate">Types from procmacros in this crate
}
</code></pre></div>
<p>Supported values:
* "enum", "trait", "callback", "trait_with_foreign"
* For records, either "record", "dictionary" or "struct"
* For objects, either "object", "impl" or "interface"</p>
* Enums: <code>enum</code>
* Records: <code>record</code>, <code>dictionary</code> or <code>struct</code>
* Objects: <code>object</code>, <code>impl</code> or <code>interface</code>
* Traits: <code>trait</code>, <code>callback</code> or <code>trait_with_foreign</code></p>
<p>eg:
<div class="highlight"><pre><span></span><code>typedef enum MyEnum;
typedef interface MyObject;
</code></pre></div>
etc.</p>
</code></pre></div></p>
<p>Note that in 0.28 and prior, we also supported this capability with a <code>[Rust=]</code> attribute.
This attribute is deprecated and may be removed in a later version.</p>

Expand Down

0 comments on commit a6b06e0

Please sign in to comment.