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

How can I dump all possible path of a deserializable struct? #2883

Open
tisonkun opened this issue Jan 16, 2025 · 2 comments
Open

How can I dump all possible path of a deserializable struct? #2883

tisonkun opened this issue Jan 16, 2025 · 2 comments

Comments

@tisonkun
Copy link

Suppose I have a Config structure that have several nested options, some of them use #[serde(tag = "type")] or more serde attrs.

I'd like to get a table of all possible paths of Config, said:

  • server.http.listern_addr is a String
  • storage.type can be s3, azblob, etc.
  • storage.bucket is a String.

Is there some way to dump such a schema?

Alternatively, I can enumerate the paths by myself, but in this case, I'd like to write a test to ensure that all the paths are valid (can exist).

@dtolnay
Copy link
Member

dtolnay commented Jan 16, 2025

@tisonkun
Copy link
Author

Good to know. Although, serde-reflection seems doesn't support #[serde(tag = "type")]:

Attributes that are not compatible with binary formats (e.g. #[serde(flatten)], #[serde(tag = ..)])

I noticed serde-reflection refers to schemars, where I'm waiting for GREsau/schemars#364.

Anyway, this may not something can be done at serde itself. Just I'd like to know if anything else I'm missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants