-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
address comments, local and registy examples, prod components instead…
… of preview in examples
- Loading branch information
Showing
34 changed files
with
1,083 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions
11
component-model/examples/tutorial/registry/adder-impl/Cargo-component.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by cargo-component. | ||
# It is not intended for manual editing. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "component-book:adder" | ||
|
||
[[package.version]] | ||
requirement = "^0.1.0" | ||
version = "0.1.0" | ||
digest = "sha256:2afffac0a89b4f6add89903754bb5a09a51378ef14f159283c1a6408abb43147" |
25 changes: 25 additions & 0 deletions
25
component-model/examples/tutorial/registry/adder-impl/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
component-model/examples/tutorial/registry/adder-impl/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "adder-impl" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
wit-bindgen-rt = { version = "0.25.0", features = ["bitflags"] } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
opt-level = "s" | ||
debug = false | ||
strip = true | ||
lto = true | ||
|
||
[package.metadata.component] | ||
package = "component-book:adder-impl" | ||
target = "component-book:adder/[email protected]" | ||
|
||
[package.metadata.component.dependencies] |
166 changes: 166 additions & 0 deletions
166
component-model/examples/tutorial/registry/adder-impl/src/bindings.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
// Generated by `wit-bindgen` 0.24.0. DO NOT EDIT! | ||
// Options used: | ||
#[allow(dead_code)] | ||
pub mod exports { | ||
#[allow(dead_code)] | ||
pub mod component_book { | ||
#[allow(dead_code)] | ||
pub mod adder { | ||
#[allow(dead_code, clippy::all)] | ||
pub mod add { | ||
#[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_add_cabi<T: Guest>(arg0: i32, arg1: i32) -> i32 { | ||
#[cfg(target_arch = "wasm32")] | ||
_rt::run_ctors_once(); | ||
let result0 = T::add(arg0 as u32, arg1 as u32); | ||
_rt::as_i32(result0) | ||
} | ||
pub trait Guest { | ||
fn add(a: u32, b: u32) -> u32; | ||
} | ||
#[doc(hidden)] | ||
|
||
macro_rules! __export_component_book_adder_add_0_1_0_cabi{ | ||
($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { | ||
|
||
#[export_name = "component-book:adder/[email protected]#add"] | ||
unsafe extern "C" fn export_add(arg0: i32,arg1: i32,) -> i32 { | ||
$($path_to_types)*::_export_add_cabi::<$ty>(arg0, arg1) | ||
} | ||
};); | ||
} | ||
#[doc(hidden)] | ||
pub(crate) use __export_component_book_adder_add_0_1_0_cabi; | ||
} | ||
} | ||
} | ||
} | ||
mod _rt { | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
pub fn run_ctors_once() { | ||
wit_bindgen_rt::run_ctors_once(); | ||
} | ||
|
||
pub fn as_i32<T: AsI32>(t: T) -> i32 { | ||
t.as_i32() | ||
} | ||
|
||
pub trait AsI32 { | ||
fn as_i32(self) -> i32; | ||
} | ||
|
||
impl<'a, T: Copy + AsI32> AsI32 for &'a T { | ||
fn as_i32(self) -> i32 { | ||
(*self).as_i32() | ||
} | ||
} | ||
|
||
impl AsI32 for i32 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for u32 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for i16 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for u16 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for i8 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for u8 { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for char { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
|
||
impl AsI32 for usize { | ||
#[inline] | ||
fn as_i32(self) -> i32 { | ||
self as i32 | ||
} | ||
} | ||
} | ||
|
||
/// Generates `#[no_mangle]` functions to export the specified type as the | ||
/// root implementation of all generated traits. | ||
/// | ||
/// For more information see the documentation of `wit_bindgen::generate!`. | ||
/// | ||
/// ```rust | ||
/// # macro_rules! export{ ($($t:tt)*) => (); } | ||
/// # trait Guest {} | ||
/// struct MyType; | ||
/// | ||
/// impl Guest for MyType { | ||
/// // ... | ||
/// } | ||
/// | ||
/// export!(MyType); | ||
/// ``` | ||
#[allow(unused_macros)] | ||
#[doc(hidden)] | ||
|
||
macro_rules! __export_adder_impl { | ||
($ty:ident) => (self::export!($ty with_types_in self);); | ||
($ty:ident with_types_in $($path_to_types_root:tt)*) => ( | ||
$($path_to_types_root)*::exports::component_book::adder::add::__export_component_book_adder_add_0_1_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::component_book::adder::add); | ||
) | ||
} | ||
#[doc(inline)] | ||
pub(crate) use __export_adder_impl as export; | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
#[link_section = "component-type:wit-bindgen:0.24.0:adder:encoded world"] | ||
#[doc(hidden)] | ||
pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 223] = *b"\ | ||
\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07d\x01A\x02\x01A\x02\x01\ | ||
B\x02\x01@\x02\x01ay\x01by\0y\x04\0\x03add\x01\0\x04\x01\x1ecomponent-book:adder\ | ||
/[email protected]\x05\0\x04\x01\x20component-book:adder/[email protected]\x04\0\x0b\x0b\x01\0\ | ||
\x05adder\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.\ | ||
202.0\x10wit-bindgen-rust\x060.24.0"; | ||
|
||
#[inline(never)] | ||
#[doc(hidden)] | ||
#[cfg(target_arch = "wasm32")] | ||
pub fn __link_custom_section_describing_imports() { | ||
wit_bindgen_rt::maybe_link_cabi_realloc(); | ||
} |
14 changes: 14 additions & 0 deletions
14
component-model/examples/tutorial/registry/adder-impl/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#[allow(warnings)] | ||
mod bindings; | ||
|
||
use bindings::exports::component_book::adder::add::Guest; | ||
|
||
struct Component; | ||
|
||
impl Guest for Component { | ||
fn add(a: u32, b: u32) -> u32 { | ||
a + b | ||
} | ||
} | ||
|
||
bindings::export!(Component with_types_in bindings); |
11 changes: 11 additions & 0 deletions
11
component-model/examples/tutorial/registry/calculator-impl/Cargo-component.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This file is automatically generated by cargo-component. | ||
# It is not intended for manual editing. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "component-book:calculator" | ||
|
||
[[package.version]] | ||
requirement = "^0.1.0" | ||
version = "0.1.0" | ||
digest = "sha256:1f75d599bae47f96644c797b824de58f161e1da7e20461da4c881568b4fd6462" |
25 changes: 25 additions & 0 deletions
25
component-model/examples/tutorial/registry/calculator-impl/Cargo.lock
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
component-model/examples/tutorial/registry/calculator-impl/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "calculator-impl" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
wit-bindgen-rt = { version = "0.25.0", features = ["bitflags"] } | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[profile.release] | ||
codegen-units = 1 | ||
opt-level = "s" | ||
debug = false | ||
strip = true | ||
lto = true | ||
|
||
[package.metadata.component] | ||
package = "component-book:calculator-impl" | ||
target = "component-book:calculator/[email protected]" | ||
|
||
[package.metadata.component.dependencies] |
Oops, something went wrong.