TheNeikos / envious

Deserialize (potentially nested) environment variables into your custom structs
Apache License 2.0
60 stars 2 forks source link

Deserialize HashMap #31

Closed curiousmindflow closed 5 months ago

curiousmindflow commented 5 months ago

Hello,

I wanted to know if it's currently possible to deserialize a HashMap ? And if not, is it part of your roadmap ?

Thank you !

TheNeikos commented 5 months ago

Heya!

I don't see why it shouldn't work. Did you try it out and encountered some issues?

curiousmindflow commented 5 months ago

I did try, but i wasn't able to see the struct updated.

I think i'm not naming the env var correctly and i didn't found example for HashMap specifically. Can you give me an example please ?

For the type:

struct Dummy {
   map0: HashMap::<String, String>,
   inner: DummyInner
}

struct DummyInner {
   map1: HashMap::<String, String>,
}
TheNeikos commented 5 months ago

I just added some tests for deserializing a hashmap:

https://github.com/TheNeikos/envious/blob/b2cd39ddf26ebba94dbe7d959e70fe37f364d02b/tests/hashmap.rs#L6-L25

Hope that helps you!

curiousmindflow commented 5 months ago

Hello,

Okay, it's working !

Really fine and helpful crate !! Thank you

TheNeikos commented 5 months ago

Awesome! :tada:

Have fun!