Skip to content

chore: correct rust integration docs to match published crate#295

Merged
mohamedmansour merged 2 commits into
mainfrom
users/janechu/fix-rust-integration-docs
May 20, 2026
Merged

chore: correct rust integration docs to match published crate#295
mohamedmansour merged 2 commits into
mainfrom
users/janechu/fix-rust-integration-docs

Conversation

@janechu

@janechu janechu commented May 16, 2026

Copy link
Copy Markdown
Contributor

What

Two small fixes to the public rust integration:

  1. crates/webui/src/lib.rs - re-export RenderOptions and Result as HandlerResult from webui_handler through the webui facade crate.
  2. docs/guide/integrations/rust.md - use the published crate name (microsoft-webui) in the install block, fix trait-impl return types, and note the rename.

Result is renamed to HandlerResult on re-export so it does not collide with the existing std::result::Result<T, E> usage inside crates/webui/src/lib.rs (build and build_to_disk).

Why

I'm integrating WebUI into an embedded host by following docs/guide/integrations/rust.md. Two things were blocking:

  • webui = "*" in Cargo.toml resolves to an unrelated crate on crates.io. The Microsoft crate is published as microsoft-webui; the [lib] name = "webui" setting keeps use webui::... working unchanged, but the docs don't mention this. This costs a first-time adopter the same hour every time.
  • The trait impls in all three framework examples reference webui_handler::Result<()> (the webui_handler crate is not the dependency the page tells you to add) and webui::RenderOptions (not currently re-exported). Copying the example into a fresh project does not compile.

The scope is intentionally narrow: just unblock the first-render-from-a-non-WebUI-host story that the page already promises.

How I tested

cargo check -p microsoft-webui

(passes after the re-export)

Happy to also copy one of the framework examples into a scratch crate that depends only on microsoft-webui to confirm the rendered text compiles end-to-end - can add that as a doctest if you'd prefer.

Notes

  • Branch is users/janechu/fix-rust-integration-docs because that's the convention my host repo uses for agent-driven branches. Happy to rename to janechu/fix-rust-integration-docs (matching the local convention in .github/skills/pr/SKILL.md) if you prefer.
  • Draft PR. There are 4 follow-up PRs queued behind this one addressing related friction in the Node integration docs, handler thread-safety docs, the @microsoft/webui/platform.js subpath export, and a fragment-rendering recipe page - opened as siblings rather than stacked.

The page instructed `cargo add webui` and `webui = "*"` in Cargo.toml,
but the bare `webui` crate on crates.io is owned by an unrelated
project. The Microsoft package is published as `microsoft-webui`; the
crate's `[lib] name = "webui"` keeps `use webui::...` imports working
unchanged when the dependency is renamed via Cargo.

The example also referenced `webui_handler::Result<()>` and
`webui::RenderOptions`. `RenderOptions` and the handler `Result` alias
are not re-exported by the `webui` crate today, so the example does not
compile against a project that only depends on `microsoft-webui`.

This PR:

- Re-exports `RenderOptions` from `webui`.
- Re-exports `Result as HandlerResult` from `webui` (renamed to avoid
  colliding with `std::result::Result` usage inside `crates/webui`).
- Updates the integration page to use `microsoft-webui = "*"`, fixes
  the trait-impl return types to `webui::HandlerResult<()>`, and adds
  a one-paragraph note explaining the published name vs the import
  namespace.

Verified by `cargo check -p microsoft-webui`.
@janechu janechu force-pushed the users/janechu/fix-rust-integration-docs branch from 52351e1 to e2b651c Compare May 16, 2026 14:46

@mohamedmansour mohamedmansour left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please fix lint

@janechu

janechu commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Fixed in e475181cargo fmt --all --check was failing because the pub use webui_handler::{...} re-export line exceeded rustfmt's line length once RenderOptions was added. Reformatted it across three lines per rustfmt. Reverified locally: cargo fmt --all --check, cargo clippy --workspace -- -D warnings, and cargo xtask license-headers all pass.

@mohamedmansour mohamedmansour merged commit 52eb521 into main May 20, 2026
21 checks passed
@mohamedmansour mohamedmansour deleted the users/janechu/fix-rust-integration-docs branch May 20, 2026 22:10
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.

2 participants