Replace trait with enum in Rust#575
Merged
baijumeswani merged 3 commits intocopilot/update-language-bindings-documentationfrom Apr 1, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Rust SDK’s model abstraction by removing the public IModel trait and replacing it with a single public Model type backed by an internal enum, avoiding boxed-future trait method signatures and simplifying the public API surface.
Changes:
- Removed the public
IModeltrait and updated the crate exports accordingly. - Reworked
Modelto wrap either a single variant or a grouped multi-variant model via an internalModelKindenum, exposing async methods directly onModel. - Updated
Catalog, examples, samples, and integration tests to useArc<Model>and the new download progress callback shape.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/rust/tests/integration/model_test.rs | Updates tests to work with Arc<Model> and the new API. |
| sdk/rust/src/lib.rs | Stops exporting IModel / removes imodel module wiring; keeps Model as the public type. |
| sdk/rust/src/imodel.rs | Deletes the public IModel trait entirely. |
| sdk/rust/src/detail/model.rs | Introduces public Model with internal ModelKind enum and async methods on the concrete type. |
| sdk/rust/src/detail/model_variant.rs | Converts variant operations to concrete async methods (no trait impl) and updates docs. |
| sdk/rust/src/catalog.rs | Updates catalog lookups/collections to return Arc<Model> (models and per-id variants). |
| sdk/rust/examples/tool_calling.rs | Updates progress callback usage for download. |
| sdk/rust/examples/interactive_chat.rs | Updates progress callback usage for download. |
| sdk/rust/examples/chat_completion.rs | Updates progress callback usage for download. |
| samples/rust/tutorial-voice-to-text/src/main.rs | Updates progress callback usage for download. |
| samples/rust/tutorial-tool-calling/src/main.rs | Updates progress callback usage for download. |
| samples/rust/tutorial-document-summarizer/src/main.rs | Updates progress callback usage for download. |
| samples/rust/tutorial-chat-assistant/src/main.rs | Updates progress callback usage for download. |
| samples/rust/tool-calling-foundry-local/src/main.rs | Updates progress callback usage for download. |
| samples/rust/native-chat-completions/src/main.rs | Updates progress callback usage for download. |
| samples/rust/foundry-local-webserver/src/main.rs | Updates progress callback usage for download (incl. move closure). |
| samples/rust/audio-transcription-example/src/main.rs | Updates progress callback usage for download. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e5851a2
into
copilot/update-language-bindings-documentation
38 of 42 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Async methods on traits require [Pin<Box>] return types, which pollute the public API.
Additionally, C# interfaces and Rust traits are not equivalent abstractions, and traits offer no obvious advantage here.
Since the set of implementors is closed and internal, an enum with private variants provides the same polymorphism with a cleaner, more idiomatic Rust API.