yassun7010 / serde_valid

JSON Schema based validation tool using serde.
MIT License
46 stars 10 forks source link

Fix compilation errors for embedded platforms like Xtensa/ESP32 #6

Closed hwmaier closed 1 year ago

hwmaier commented 1 year ago

serde_valid is a very useful add-on for serde deserializations.

This PR contains changes to compile it for embedded platforms which don't autodetect std feature and i128 feature. Specifically the ESP32 platform.

To compile there, indexmap needs feature std enabled. In addition num_traits won't have the traits for i128 enabled, so this PR makes the numeric_multiple_of validations for 128-bit integers only available if the i128 feature is enabled and avoids a compilation error if not.

hwmaier commented 1 year ago

Alternatively to adding #[cfg(feature = "num-traits/i128")] it may be better to add the i128 feature to the num_traits package in Cargo.toml:

num-traits = { version = "^0.2", features = ["i128"] } 
yassun7010 commented 1 year ago

Thanks for the PR.

I prefer to add "#[cfg(feature = "num-traits/i128")]".

I will release it as soon as possible after you fix it!

hwmaier commented 1 year ago

I prefer to add "#[cfg(feature = "num-traits/i128")]".

I will release it as soon as possible after you fix it!

Hi @yassun4dev, I reverted my last commit to use your preferred #[cfg(feature = "num-traits/i128")] solution.

yassun7010 commented 1 year ago

@hwmaier I released v0.15.0.

I found that some of my applications that use i128 fail to compile, so I ended up adding the i128 feature.

For backward compatibility, the i128 feature is supported by default, and can be used without editing the settings in Cargo.toml.

hwmaier commented 1 year ago

I found that some of my applications that use i128 fail to compile, so I ended up adding the i128 feature.

Great. I checked the latest v0.15.0 release today and compiled it for the embedded ESP32 platform and all compiles without error out of the box.

Thank you so much for incorporating these changes.