Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inner types of ignored external types are generated anyway #557

Open
gshep opened this issue Sep 29, 2024 · 4 comments
Open

Inner types of ignored external types are generated anyway #557

gshep opened this issue Sep 29, 2024 · 4 comments

Comments

@gshep
Copy link
Member

gshep commented Sep 29, 2024

Problem

Not sufficient however would be nice to fix it. Generated Rust code contains redundant entities however they are inner types of ignored external ones.

Steps

  1. the same as in Generated Rust code from idl with set external type requires PartialEq #556
  2. generated idl_external_type_client.rs will contain the Inner struct. The file excerpt is attached.

Possible Solution

The basic idea is to make two passes. During the first pass populate inner external_types map. On the second pass the current logic is kept.

Notes

No response

Relevant Log Output

Click to expand/collapse

#[derive(PartialEq, Debug, Encode, Decode, TypeInfo)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub struct Message(pub Data);
#[derive(PartialEq, Debug, Encode, Decode, TypeInfo)]
#[codec(crate = sails_rs::scale_codec)]
#[scale_info(crate = sails_rs::scale_info)]
pub struct Inner(pub u32);

pub mod traits {

@DennisInSky
Copy link
Member

We can't skip generating types as IDL is used for generating clients not just for Rust, but for other languages as well where external Rust crates are unavailable

@gshep gshep reopened this Sep 30, 2024
@gshep
Copy link
Member Author

gshep commented Sep 30, 2024

reopened since we discussed it in dm

@DennisInSky
Copy link
Member

A possible solution would be recursively marking a type as external provided it is referenced from another type marked as external.

@gshep
Copy link
Member Author

gshep commented Oct 1, 2024

It would be also nice to prefix such external types with pub

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

No branches or pull requests

2 participants