Skip to content

Alternative Rust Build Tooling #1048

@atm1150

Description

@atm1150

Related to an existing integration?

Yes

Existing integration

CommunityToolkit.Aspire.Hosting.Rust

Overview

Currently the rust integration requires that the build tool used is cargo but also the user is forced to use the "run" command as well. For the vast majority of rust programs this is more than sufficient but there are use cases that either use alternative build tools or sometimes people extend the cargo build tool to allow for additional functionality during development. Below are links to the trunk build tool which is meant for CSR style WASM workloads while the other is an extension to cargo for the Leptos framework that is used in their SSR and hybrid deployment models.

https://trunkrs.dev/
https://github.com/leptos-rs/cargo-leptos?tab=readme-ov-file

I personally believe it is beneficial to refactor the current "AddRustApp" method to allow for these alternative tools as this will allow for a single central place to integrate rust code into Aspire but also to prevent integration creep from every rust framework in existence having to add its own integration rather than working through the existing rust code. It is my opinion that the current code can be refactored to allow for alternative build tools/commands while not creating any breaking changes. My proposed refactor includes the use of optional parameters to ensure that current code not only does not break, but also maintains the default setting of "cargo run" being the preferred tooling process which even if a full rewrite was done I would absolutely agree that such should be the default setting to prevent users from shooting themselves in the foot. Below I will show some example pictures of my code changes to see if the maintainers here agree with my changes or can point out special cases that would become broken due to my code so I can attempt to find another solution. I will also provide a link to my fork of this branch

https://github.com/atm1150/Aspire/tree/leptos-integration

The two main changes in this fork are in the RustAppExecutableResource and in its AddRustApp extension method. The executable resource is changed to allow an optional param that will be passed to the ExecutableResource base class constructor rather requiring cargo alone. The executable resource file also contains a new RustBuildOptions class that is optionally passed into the AddRustApp extension method and if one is passed into it then the default tooling config of "cargo run" is replaced with the RustBuildOptions values.

Usage example

Image

Breaking change?

I'm not sure

Alternatives

The best alternative as I see is to have a full and singular integration for each separate rust framework or build process that does not utilize the default "cargo run" and I believe this is a disadvantage over time as it creates further integrations that must be maintained or it requires that all people not using "cargo run" must always write their rust based resources from scratch.

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions