BEP 9 (the protocol for resolving magnet URIs) defines a data packet that consists of a bencoded dictionary followed by arbitrary data (actually a slice of a torrent's info dict), and I would like to parse such a packet using bendy. The best way I've figured out to do this so far is to create a Decoder, call next_object(), retrieve the DictDecoder, iterate through & massage the dict's fields, call DictDecoder::into_raw() after handling all fields, get the length of the raw dict, and use that length as an offset to slice the original payload. This is rather unwieldy, and I believe this could be simplified by just giving Decoder a remaining(self) -> &'ser [u8] method for retrieving all remaining bytes of the payload after doing next_object() + FromBencode::decode_bencode_object().
BEP 9 (the protocol for resolving magnet URIs) defines a data packet that consists of a bencoded dictionary followed by arbitrary data (actually a slice of a torrent's info dict), and I would like to parse such a packet using bendy. The best way I've figured out to do this so far is to create a
Decoder, callnext_object(), retrieve theDictDecoder, iterate through & massage the dict's fields, callDictDecoder::into_raw()after handling all fields, get the length of the raw dict, and use that length as an offset to slice the original payload. This is rather unwieldy, and I believe this could be simplified by just givingDecoderaremaining(self) -> &'ser [u8]method for retrieving all remaining bytes of the payload after doingnext_object()+FromBencode::decode_bencode_object().