Help migrate Rig code between versions. Use when upgrading rig-core or companion crates, resolving breaking changes, or updating deprecated APIs. Detects the current version from Cargo.toml automatically.
Current project Rig version (auto-detected):
!`grep -E '^rig-core|^rig ' Cargo.toml 2>/dev/null || grep -rE 'rig-core\s*=' Cargo.toml */Cargo.toml 2>/dev/null | head -5 || echo "rig-core version not found in Cargo.toml"`
Latest Rig release:
!`cargo search rig-core --limit 1 2>/dev/null || echo "Could not fetch latest version. Check https://crates.io/crates/rig-core"`
cargo fmtcargo clippy --all-targets --all-featurescargo testAll trait bounds must use WASM-compatible variants:
// Before
pub trait MyTrait: Send + Sync {
fn method(&self) -> impl Future<Output = ()> + Send;
}
// After
use rig::{WasmCompatSend, WasmCompatSync};
pub trait MyTrait: WasmCompatSend + WasmCompatSync {
fn method(&self) -> impl Future<Output = ()> + WasmCompatSend;
}
Search pattern: grep -rn ': Send\b\|+ Send\b\|: Sync\b\|+ Sync\b' --include='*.rs'
// Before
fn process() -> Result<(), String> { ... }
// After
#[derive(Debug, thiserror::Error)]
enum ProcessError {
#[error("Parse failed: {0}")]
Parse(#[from] serde_json::Error),
}
fn process() -> Result<(), ProcessError> { ... }
Search pattern: grep -rn 'Result<.*,\s*String>' --include='*.rs' (results should be manually verified to avoid false positives)
When providers update their APIs, Rig's type definitions change. Check the CHANGELOG for specific field additions/removals.
Typical changes:
GPT_4 -> GPT_4O)CompletionRequest now has an optional model field:
// When constructing CompletionRequest manually, include the field:
let request = CompletionRequest {
model: None, // or Some("model-override".to_string())
preamble: None,
chat_history: OneOrMany::one("Hello".into()),
// ... rest of fields
};
Use this checklist when migrating:
rig-core version in all Cargo.toml filesrig-mongodb, rig-lancedb, etc.)Send/Sync with WasmCompatSend/WasmCompatSyncString error types with proper error enums.unwrap() / .expect() on fallible operationscargo fmt && cargo clippy --all-targets --all-features && cargo test