Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the example to use the latest version of cargo-component #283

Merged
merged 1 commit into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions example/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
wit-bindgen-rt = { version = "0.23.0", features = ["bitflags"] }
wit-bindgen-rt = { version = "0.24.0", features = ["bitflags"] }

[package.metadata.component]
package = "example:component"
Expand Down
31 changes: 18 additions & 13 deletions example/src/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Generated by `wit-bindgen` 0.20.0. DO NOT EDIT!
// Generated by `wit-bindgen` 0.24.0. DO NOT EDIT!
// Options used:
#[allow(dead_code)]
pub mod example {
#[allow(dead_code)]
pub mod component {

#[allow(clippy::all)]
#[allow(dead_code, clippy::all)]
pub mod cache {
#[used]
#[doc(hidden)]
Expand Down Expand Up @@ -78,7 +79,7 @@ pub mod example {
}
}

#[allow(clippy::all)]
#[allow(dead_code, clippy::all)]
pub mod backend {
#[used]
#[doc(hidden)]
Expand Down Expand Up @@ -118,22 +119,25 @@ pub mod example {
}
}
}
#[allow(dead_code)]
pub mod exports {
#[allow(dead_code)]
pub mod example {
#[allow(dead_code)]
pub mod component {

#[allow(clippy::all)]
#[allow(dead_code, clippy::all)]
pub mod backend {
#[used]
#[doc(hidden)]
#[cfg(target_arch = "wasm32")]
static __FORCE_SECTION_REF: fn() =
super::super::super::super::__link_custom_section_describing_imports;
use super::super::super::super::_rt;

#[doc(hidden)]
#[allow(non_snake_case)]
pub unsafe fn _export_fetch_cabi<T: Guest>(arg0: *mut u8, arg1: usize) -> *mut u8 {
#[cfg(target_arch = "wasm32")]
_rt::run_ctors_once();
let len0 = arg1;
let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0);
let result1 = T::fetch(_rt::string_lift(bytes0));
Expand All @@ -146,7 +150,6 @@ pub mod exports {
*ptr2.add(0).cast::<*mut u8>() = ptr3.cast_mut();
ptr2
}

#[doc(hidden)]
#[allow(non_snake_case)]
pub unsafe fn __post_return_fetch<T: Guest>(arg0: *mut u8) {
Expand All @@ -165,12 +168,10 @@ pub mod exports {
macro_rules! __export_example_component_backend_cabi{
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = {


#[export_name = "example:component/backend#fetch"]
unsafe extern "C" fn export_fetch(arg0: *mut u8,arg1: usize,) -> *mut u8 {
$($path_to_types)*::_export_fetch_cabi::<$ty>(arg0, arg1)
}

#[export_name = "cabi_post_example:component/backend#fetch"]
unsafe extern "C" fn _post_return_fetch(arg0: *mut u8,) {
$($path_to_types)*::__post_return_fetch::<$ty>(arg0)
Expand All @@ -179,7 +180,6 @@ pub mod exports {
}
#[doc(hidden)]
pub(crate) use __export_example_component_backend_cabi;

#[repr(align(4))]
struct _RetArea([::core::mem::MaybeUninit<u8>; 8]);
static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]);
Expand All @@ -196,6 +196,11 @@ mod _rt {
core::hint::unreachable_unchecked()
}
}

#[cfg(target_arch = "wasm32")]
pub fn run_ctors_once() {
wit_bindgen_rt::run_ctors_once();
}
pub unsafe fn string_lift(bytes: Vec<u8>) -> String {
if cfg!(debug_assertions) {
String::from_utf8(bytes).unwrap()
Expand Down Expand Up @@ -244,7 +249,7 @@ macro_rules! __export_example_impl {
pub(crate) use __export_example_impl as export;

#[cfg(target_arch = "wasm32")]
#[link_section = "component-type:wit-bindgen:0.20.0:example:encoded world"]
#[link_section = "component-type:wit-bindgen:0.24.0:example:encoded world"]
#[doc(hidden)]
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 354] = *b"\
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xe4\x01\x01A\x02\x01\
Expand All @@ -254,7 +259,7 @@ e\x05\0\x01B\x03\x01p}\x01@\x01\x03urls\0\0\x04\0\x05fetch\x01\x01\x03\x01\x19ex
ample:component/backend\x05\x01\x01B\x03\x01p}\x01@\x01\x03urls\0\0\x04\0\x05fet\
ch\x01\x01\x04\x01\x19example:component/backend\x05\x02\x04\x01\x19example:compo\
nent/example\x04\0\x0b\x0d\x01\0\x07example\x03\0\0\0G\x09producers\x01\x0cproce\
ssed-by\x02\x0dwit-component\x070.201.0\x10wit-bindgen-rust\x060.20.0";
ssed-by\x02\x0dwit-component\x070.202.0\x10wit-bindgen-rust\x060.24.0";

#[inline(never)]
#[doc(hidden)]
Expand Down