Skip to content

Update rust guide and tutorial examples to use registries for WITs #251

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

Conversation

kate-goldenring
Copy link
Collaborator

The adder and calculator worlds are now published to GHCR. This updates the Rust docs to use those WITs from GHCR.

@vados-cosmonic @mkatychev this should help make the Rust guide experience smoother

@mkatychev
Copy link
Contributor

This is awesome, going to take a deeper look first thing tomorrow.

[package.metadata.component.target]
path = "../wit/adder"
world = "adder"
package = "docs:adder"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really slick now!

Copy link
Contributor

@vados-cosmonic vados-cosmonic Apr 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! I've sometimes been accused of being too verbose, but what do you all think about a comment line near this explaining how this works?

A small blurb (or even a link) to let people know that BCA packages are automatically pullable from a known registry (which is recognized by/built into cargo component), and maybe a link to docs and/or the OCI repo. I see that we have the registry key in here which should make things a bit easier to figure out!

Heavily commented configuration files are often an underrated entry point for understanding how things work IMO, and explaining a little bit of the magic here would be nice.

[EDIT] How about leaving the world in here? IMO it's nice to be overly explicit -- while single-world WIT interfaces can have their world auto-selected, I personally prefer people thinking about this actively up until they optimize that away (and only people who care about absolutely minimal configuration files will do that anyway).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there may be a bug in cargo-componen because when i add a world to reference, i get this error:

error: failed to create a target world for package `adder` (/Users/kagold/Programs/component-docs/component-model/examples/tutorial/adder/Cargo.toml)

Caused by:
    0: failed to select world from target package `docs:adder`
    1: no world named `adder` in package

For now, i'll leave the world out but ill file an issue with cargo-component

[package.metadata.component.target]
path = "../wit/adder"
world = "adder"
package = "docs:adder"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have another example (or text) which shows people how to use a local WIT file? I am cautious lest the second thing they do is "ooh let me try this with my own interface" and bam, they're lost.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add in docs on that or we can have the calculator component take the local filesystem approach. Maybe both?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - whatever works out to be more convenient is fine!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To both example implementations I added local and registry options to the Cargo.toml and in the Rust doc I added a note on how to use local files instead

@kate-goldenring kate-goldenring force-pushed the rust-fetch-wit-from-ghcr branch from a809649 to 8316393 Compare May 1, 2025 18:53
@kate-goldenring
Copy link
Collaborator Author

@itowlson @vados-cosmonic this is ready for another review

Copy link
Collaborator

@itowlson itowlson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @kate-goldenring - the registries stuff definitely provides an easier ramp for readers following the tutorial!

Copy link
Contributor

@mkatychev mkatychev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kate-goldenring kate-goldenring force-pushed the rust-fetch-wit-from-ghcr branch from 8316393 to 7ea483e Compare May 2, 2025 15:05
@kate-goldenring kate-goldenring merged commit f06eb4f into bytecodealliance:main May 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants