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
There is a new feature not to generate new entities from IDL file - #538 .
However new types with external entities used in a service will have derive(PartialEq) attribute whereas the external entities don't implement the trait.
Steps
cargo sails new-program idl-external-type
create sample shared crated: cd idl-external-type/ & cargo new --lib common
Check to attached log for the compiler error output.
Possible Solution
No response
Notes
It is not an issue to derive PartialEq in that very case. However it not quite correct overall.
Relevant Log Output
Click to expand/collapse
error[E0369]: binary operation `==` cannot be applied to type `Data`
--> /Users/user/devel/gear-tech/sails/idl-external-type/target/debug/build/idl-external-type-client-200f8f28330f558c/out/idl_external_type_client.rs:97:20
|
94 | #[derive(PartialEq, Debug, Encode, Decode, TypeInfo)]
| --------- in this derive macro expansion
...
97 | pub struct Message(pub Data);
| ^^^^^^^^
|
note: the foreign item type `Data` doesn't implement `sails_rs::PartialEq`
--> /Users/user/devel/gear-tech/sails/idl-external-type/common/src/lib.rs:13:1
|
13 | pub struct Data(pub Inner);
| ^^^^^^^^^^^^^^^ not implement `sails_rs::PartialEq`
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)
The text was updated successfully, but these errors were encountered:
We need to take a decision whether it is better to generate Rust code according to rules of thumb, i.e. generate implementations for common traits like PartialEq, Clone, Debug or minimize a number of requirements on code used for client generation assuming the traits like PartialEq, Clone will not be used frequently, and if they are needed, one can implement them manually in the crate which includes code generate for client.
Another assumption in taking decision might be it shouldn't be a big issue for user to derive impls for the traits in question provided the types used for contracts are internal to this contract
Problem
There is a new feature not to generate new entities from IDL file - #538 .
However new types with external entities used in a service will have
derive(PartialEq)
attribute whereas the external entities don't implement the trait.Steps
cargo sails new-program idl-external-type
cd idl-external-type/
&cargo new --lib common
idl-external-type/app/src/lib.rs
:.with_external_type("Data", "common::Data")
toclient/build.rs
It produces the following code (in
idl_external_type_client.rs
):Check to attached log for the compiler error output.
Possible Solution
No response
Notes
It is not an issue to derive
PartialEq
in that very case. However it not quite correct overall.Relevant Log Output
Click to expand/collapse
The text was updated successfully, but these errors were encountered: