toby / serde-bencode

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

Print what field gives a serializa/deserialize error #42

Open vrnvu opened 4 months ago

vrnvu commented 4 months ago

I was trying to write the PR myself but the code is quite confusing for me sorry.

The idea is that instead of a generic error:

Invalid Type: byte array (expected: a sequence)

A serializing library should give you the position, in this case we should know what field we are trying to parse:

Invalid Type for field "pieces": byte array (expected: a sequence)

josecelano commented 4 months ago

I was trying to write the PR myself but the code is quite confusing for me sorry.

The idea is that instead of a generic error:

Invalid Type: byte array (expected: a sequence)

A serializing library should give you the position, in this case we should know what field we are trying to parse:

Invalid Type for field "pieces": byte array (expected: a sequence)

Hi @vrnvu I had the same problem when I started using the library. I think that would be a very useful feature.