toby / serde-bencode

Serde backed Bencode encoding/decoding library for Rust.
MIT License
65 stars 16 forks source link

Fix deserialization of adjacently tagged enums #23

Closed madadam closed 3 years ago

madadam commented 3 years ago

This PR fixes the inability of this crate to deserialize into an adjacently tagged enum and also to a flattened adjacently tagged enum. The first was caused because the enum tag is handled using a visitor (defined inside serde itself) which only defines visit_str, but this crate's Deserializer forwarded deserialize_str into deserialize_any which in turn calls visit_bytes. The fix is to explicitly define deserialize_str which calls visit_str. The second issue is similar but needed explicit definition of deserialize_identifier instead, also calling visit_str.

This PR also applies rustfmt (with the default settings) in the first commit and fixes compiler and clippy warnings in the second. I believe this is useful to make future contributions to this project easier. If you disagree, I'm OK with taking those two commit out or to put them into a separate PR if you prefer.

Closes #24

toby commented 3 years ago

Awesome! Thank you for this. I'm also looking for someone to help me to maintain this lib. Would you be interested?

madadam commented 3 years ago

Cool, thanks!

I'm also looking for someone to help me to maintain this lib. Would you be interested?

Sure, why not. Anything in particular you have in mind?

toby commented 3 years ago

Cool, thanks!

I'm also looking for someone to help me to maintain this lib. Would you be interested?

Sure, why not. Anything in particular you have in mind?

General maintenance for the most part. I've been mostly focused on Go libraries, so haven't had the time to put into this one. I can add you as a maintainer.