From c56cc2444c661acf82990480e110350b5f9e2c01 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 31 Aug 2023 17:50:26 +0200 Subject: [PATCH] Document the `ownership` key of the `bindgen!` macro (#6941) --- crates/wasmtime/src/component/mod.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/wasmtime/src/component/mod.rs b/crates/wasmtime/src/component/mod.rs index 4129975def45..b8e79df1fd45 100644 --- a/crates/wasmtime/src/component/mod.rs +++ b/crates/wasmtime/src/component/mod.rs @@ -293,6 +293,20 @@ pub(crate) use self::store::ComponentStoreData; /// interface::ErrorType: RustErrorType, /// }, /// +/// // All generated bindgen types are "owned" meaning types like `String` +/// // are used instead of `&str`, for example. This is the default and +/// // ensures that the same type used in both imports and exports uses the +/// // same generated type. +/// ownership: Owning, +/// +/// // Alternative to `Owning` above where borrowed types attempt to be used +/// // instead. The `duplicate_if_necessary` configures whether duplicate +/// // Rust types will be generated for the same WIT type if necessary, for +/// // example when a type is used both as an import and an export. +/// ownership: Borrowing { +/// duplicate_if_necessary: true +/// }, +/// /// // Restrict the code generated to what's needed for the interface /// // imports in the inlined WIT document fragment. /// interfaces: "