Coder Social home page Coder Social logo

Comments (2)

peterhuene avatar peterhuene commented on June 6, 2024

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.

Gordon-F avatar Gordon-F commented on June 6, 2024

@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.:

  1. Create an entity
  2. Attach script (Lua, C#, etc.)
  3. Write some code
  4. 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.