You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The port of additional test cases (#20) to fix issue #7 revealed a new question. The original test suite contained some cases marked as "illegal" which contain more tokens than actually required to restore the expected data type. Example: Decoding i12345e5:hellointo an integer.
How should FromBencode handle the case? Potential solutions I can think of:
silently drop them (as we do right now)
return an error variant which contains the unused tokens
add an additional default implementation next to from_bencode with stricter handling
The text was updated successfully, but these errors were encountered:
I think the best solution is something like the last one, but we make from_bencode return a Result<(Self, &[u8]), Error> (where the &[u8] is what's left in the input string), and then have a from_bencode_complete that converts the case where there's something left into an error
I'm not firm on the naming; I'd also be OK with from_bencode_partial and from_bencode for the current behaviour and the new behaviour, respectively
The port of additional test cases (#20) to fix issue #7 revealed a new question. The original test suite contained some cases marked as "illegal" which contain more tokens than actually required to restore the expected data type. Example: Decoding
i12345e5:hello
into an integer.How should
FromBencode
handle the case? Potential solutions I can think of:from_bencode
with stricter handlingThe text was updated successfully, but these errors were encountered: