lumeohq / xsd-parser-rs

A xsd/wsdl => rust code generator written in rust
Apache License 2.0
97 stars 35 forks source link

UtilsTupleIo, UtilsDefaultSerde derive macros and Validate trait #97

Open mlevkov opened 4 years ago

mlevkov commented 4 years ago

Hello,

Thank you for your effort. I would like to ask how to activate the derive UtilsTupleIo, UtilsDefaultSerde? There is a frequent reference to the UtilsTupleIo, UtilsDefaultSerde, however, it is unclear as to what I need to include in the project in order to allow for these to exist over the struct. I've noticed that Validate is attached to the custom type, however, no reference is generated in the code base for such. Having to examine your code, even the one that is generated by default from the XML-parser binary, I see no definition of trait at all. However, I went about and added in my project, but I'm not certain whether that is the intended outcome.

Also, would it make sense to include some of your de/se overrides within the Yaserde library, instead of keeping it within your custom effort? I'm referring to UtilsTupleIo, UtilsDefaultSerde?

Thank you so much.

DmitrySamoylov commented 4 years ago

Hi! Currently we don't generate imports. You can look how we import dependent types and macros in tests

Generated code currently depends on three crates:

macro-utils = { git = "https://github.com/lumeohq/xsd-parser-rs" }
xsd-types = { git = "https://github.com/lumeohq/xsd-parser-rs" }
xsd-parser = { git = "https://github.com/lumeohq/xsd-parser-rs" }

First one is for UtilsTupleIo, UtilsDefaultSerde macros The second one is for XSD builtin types like NonNegativeInteger Third one is parser itself from which we only need Validate trait definition

Probably it is not very convenient for the user at the moment but I think it'll change once we introduce generating use's for each generated Rust module. And at some point we'll add re-exporting for all the types used in the generated code.

Regarding moving certain ser/de macros to Yaserde, I agree it is better to be done in yaserde. Just need to make yaserde work with structs with unnamed fields like this pub struct A(pub String)

victor-soloviev commented 4 years ago

Dmitry already has mentioned tests, but you can also look at how it's done in the onvif-rs repo, which is generated using this parser.

mlevkov commented 4 years ago

Thank you so much. I will try all of these.