From a6b06e097e9d455f1d0cbe7d4ca31b8fab8cbe35 Mon Sep 17 00:00:00 2001 From: "uniffi-docs[bot]" Date: Wed, 7 Aug 2024 13:29:26 +0000 Subject: [PATCH] Deployed 33a24e6cf to next with MkDocs 1.6.0 and mike 2.1.1 --- next/futures.html | 24 ++++++++++++++++++++ next/tutorial/foreign_language_bindings.html | 13 +++++------ next/udl/ext_types.html | 10 ++++---- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/next/futures.html b/next/futures.html index 45603af883..608920527a 100644 --- a/next/futures.html +++ b/next/futures.html @@ -898,6 +898,15 @@ + + +
  • + + + Cancelling async code. + + +
  • @@ -1459,6 +1468,15 @@ + + +
  • + + + Cancelling async code. + + +
  • @@ -1549,6 +1567,12 @@

    Python: uniffi_set_event_loop()uniffi_set_event_loop() to handle this case. It should be called before the Rust code makes the async call and passed an eventloop to use.

    Note that uniffi_set_event_loop cannot be glob-imported because it's not part of the library's __all__.

    +

    Cancelling async code.

    +

    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 cancel() method that sets a flag that the library checks periodically.

    +

    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 CancellationError).

    +

    See also https://github.com/mozilla/uniffi-rs/pull/1768.

    diff --git a/next/tutorial/foreign_language_bindings.html b/next/tutorial/foreign_language_bindings.html index f2b87a74ca..fb5807cbf9 100644 --- a/next/tutorial/foreign_language_bindings.html +++ b/next/tutorial/foreign_language_bindings.html @@ -1534,9 +1534,9 @@

    Foreign-language bindings

    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.

    Creating the bindgen binary

    First, make sure you have installed all the prerequisites.

    -

    Ideally you would then run the uniffi-bindgen binary from the uniffi crate to generate your bindings. However, this -is only available with Cargo nightly. -To work around this, you need to create a binary in your project that does the same thing.

    +

    Ideally you would then run the uniffi-bindgen binary from the uniffi crate to generate your bindings, +but if not on Cargo nightly, +you need to create a binary in your project that does the same thing.

    Add the following to your Cargo.toml:

    [[bin]]
     # This can be whatever name makes sense for your project, but the rest of this tutorial assumes uniffi-bindgen.
    @@ -1550,11 +1550,10 @@ 

    Creating the bindgen binary

    You can now run uniffi-bindgen from your project using cargo run --features=uniffi/cli --bin uniffi-bindgen [args]

    Multi-crate workspaces

    -

    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 uniffi-bindgen: - - Name the crate uniffi-bindgen +

    In a multiple crates workspace, you can create a separate crate for running uniffi-bindgen: + - Name the crate uniffi-bindgen, add it to your workspace. - Add this dependency to Cargo.toml: uniffi = {version = "0.XX.0", features = ["cli"] } - - Follow the steps from the previous section to add the uniffi-bindgen binary target

    + - As above, add the uniffi-bindgen binary target

    Then your can run uniffi-bindgen from any crate in your project using cargo run -p uniffi-bindgen [args]

    Running uniffi-bindgen using a library file

    Use generate --library to generate foreign bindings by using a cdylib file built for your library. diff --git a/next/udl/ext_types.html b/next/udl/ext_types.html index e181536a6d..20a9fd999f 100644 --- a/next/udl/ext_types.html +++ b/next/udl/ext_types.html @@ -1459,14 +1459,14 @@

    Types from procmacros in this crate }

    Supported values: -* "enum", "trait", "callback", "trait_with_foreign" -* For records, either "record", "dictionary" or "struct" -* For objects, either "object", "impl" or "interface"

    +* Enums: enum +* Records: record, dictionary or struct +* Objects: object, impl or interface +* Traits: trait, callback or trait_with_foreign

    eg:

    typedef enum MyEnum;
     typedef interface MyObject;
    -
    -etc.

    +

    Note that in 0.28 and prior, we also supported this capability with a [Rust=] attribute. This attribute is deprecated and may be removed in a later version.