arjantop/rust-bencode

Question

aochagavia opened this issue · 4 comments

Sorry I opened this just to ask a question... It seems to be the only place to do it.

Does your library support decoding when some elements might or might not be present? I think this is very important, specially when decoding .torrent files, because there are many optional fields according to the BitTorrent Protocol.

Another question is: does the library support getting the binary representation of a dictionary? This is needed in order to compute the sha1 hash of the info dictionary contained in .torrent files.

Yes, all Option<T> struct fields are optional.

For a binary representation you will just have to encode it again.

I am not sure if encoding again will do it. The problem is that the order of the encoded elements may change after encoding and decoding. Is this correct?

No, bencode dictionary keys must be encoded in sorted order

Nice, thanks!