You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where sign method's key arg should be &Key instead of KeyBorrow
and fails to compile since the KeyBorrow type does not exist
The WIT for the calvinrp:scratch-example is shown here:
packagecalvinrp:scratch-example@0.0.1;/// An example world for the component to target.worldexample {
exportservice;
}
interfaceservice {
useother.{key};
sign:func(key:borrow<key>) ->string;
}
interfaceother {
resourcekey {}
}
The text was updated successfully, but these errors were encountered:
calvinrp
changed the title
Bindings are sometimes type + Borrow suffix vs & type
Bindings are sometimes incorrectly generated type + Borrow suffix vs & type
May 20, 2024
OK, figured it out. If the interface types are exported in the target world, then wit-bindgen-rust uses SomeBorrow instead of &Some. But cargo-component doesn't implement the same logic.
Expanded test cases to cover issue #299
Also, when specifying an exact semver requirement, adds that exact requirement to the generated Cargo.toml. There was mismatch before.
wit-bindgen-rust generates different bindings for borrow<> of resources, depending on whether that type is exported in the world or not. &SomeType vs SomeTypeBorrow in the generated bindings. Fixed the logic here to match that behavior. The revised test case should better cover future potential breakage.
If interested, here is some of the logic on the wit-bindgen side:
https://github.com/bytecodealliance/wit-bindgen/blob/main/crates/rust/src/interface.rs#L2203-L2225
cargo component new --lib --target calvinrp:scratch-example --registry https://calvinrp.wa.dev scratch-example
generates:
where
sign
method'skey
arg should be&Key
instead ofKeyBorrow
and fails to compile since the
KeyBorrow
type does not existThe WIT for the
calvinrp:scratch-example
is shown here:The text was updated successfully, but these errors were encountered: