-
Notifications
You must be signed in to change notification settings - Fork 63
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# This file is automatically generated by cargo-component. | ||
# It is not intended for manual editing. | ||
version = 1 | ||
|
||
[[package]] | ||
name = "docs:adder" | ||
registry = "ghcr.io/bytecodealliance" | ||
|
||
[[package.version]] | ||
requirement = "^0.1.0" | ||
version = "0.1.0" | ||
digest = "sha256:d4cb950366f8756821c401ec496ad43b35ffb0df3b2e757eb6aa3c1fa30d38c2" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,17 @@ wit-bindgen-rt = { version = "0.37.0", features = ["bitflags"] } | |
[lib] | ||
crate-type = ["cdylib"] | ||
|
||
[package.metadata.component] | ||
# Tell cargo-component where to find the package for the target world | ||
# The following tells cargo-component to fetch the WIT from ghcr.io/bytecodealliance/docs/adder:0.1.0 | ||
[package.metadata.component.target] | ||
# The registry which contains the package | ||
registry = "ghcr.io/bytecodealliance" | ||
# The package name | ||
package = "docs:adder" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add in docs on that or we can have the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good - whatever works out to be more convenient is fine! There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
# The package version | ||
version = "0.1.0" | ||
|
||
[package.metadata.component.dependencies] | ||
|
||
[package.metadata.component.target] | ||
path = "../wit/adder" | ||
world = "adder" | ||
# # To instead use a WIT on the local filesystem, uncomment the following lines | ||
# [package.metadata.component.target] | ||
# # Path to the directory containing the WIT | ||
# path = "../wit/adder" |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 intoI see that we have thecargo component
), and maybe a link to docs and/or the OCI repo.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).There was a problem hiding this comment.
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:
For now, i'll leave the world out but ill file an issue with cargo-component