Comments (2)
Hi @Gordon-F. Thanks for the question!
Unfortunately there is no way to define multiple components in a single cargo-component
project currently.
cargo-component
is designed to only produce a single WebAssembly component; in this case, a single component wasm file defining a single nested WebAssembly module implementing the component.
However, it is possible do define multiple nested components in a WebAssembly component. In theory, a separate tool could be implemented to take multiple WebAssembly components and bundle them together into a single component that exports the inner components. Even so, there would be the requirement of having multiple cargo-component
projects.
It is also possible to statically share code between multiple Rust components using normal crate dependencies, but each component will get their own copy of the code.
Could you explain more about the desire to define multiple components in a project? Is it simply to bundle them together or do you envision the components to be able to share a single copy of code?
from cargo-component.
@peterhuene thank you for the explanation!
Could you explain more about the desire to define multiple components in a project? Is it simply to bundle them together or do you envision the components to be able to share a single copy of code?
Currently, I'm trying to prototype a scripting system for a game engine based on WASM. And I want to use Rust as one of the scripting languages.
For example, a scenario with existing game engines like Unity/Godot/Defold/etc.:
- Create an entity
- Attach script (Lua, C#, etc.)
- Write some code
- Hit the run button and test game
If we try to re-implement this with Rust as a scripting language, we should create a new crate
for every new script. Unfortunately, this is not very convenient. I thought that cargo-component
may help here.
from cargo-component.
Related Issues (20)
- Integration with rust-analyzer is broken for bindings HOT 12
- component build doesn't seems to respect local world prefix HOT 7
- Adding custom derive attributes HOT 2
- `cargo_component_bindings::generate!()` requires component implementation in the same mod HOT 2
- Validation of reactor component fails due to missing _start export HOT 1
- issue installing cargo-component βnote: perhaps two different versions of crate wit_parser are being used" HOT 2
- Imported component dependency has wrong type on execution HOT 4
- Consider adding binaries to the release artifacts HOT 3
- `check` doesn't seem to generate the file bindings HOT 4
- compose failed caused by lack of wasi:***.wasm when following the tutorial HOT 1
- How to build `wat` for preview? HOT 2
- Support multiple target dependencies with the same package id but different versions.
- Build Failure with Inline WIT with `wit-bindgen` HOT 6
- Document `package.metadata.component` configuration HOT 4
- Rust-analyzer doesn't integrate bindings in workspace HOT 1
- Consider reverting `--reactor` to `--lib` HOT 4
- Conventions for namespaces generated by macros HOT 3
- How to use cargo-component for subprojects? HOT 2
- Generate better cargo check command for vscode HOT 1
- Consider using `cargo add` in the `new` command HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-component.