Crate sveppa_bencode

Crate sveppa_bencode 

Source
Expand description

A zero dependency library to implement parsing the bencode format into a usable Bencode enum.

Each Bencode object can be destructured into its value easily with the methods (as_usize, as_bytes, as_map, as_list, as_string).

Due to the limitations of the rust typing system you are able to call any of these methods on any of the variants of the Bencode enum.

If a destructuring method is called on the improper variant it will return an InvalidVariantMethod error, which will tell you which function was called, and the variant that was passed to it.

test

Enums§

Bencode
A nested enum containing the parsed Bencode file structure.
BencodeParserError
Possible error values when parsing a bencode struct into a value, or utf8 bytes into a bencode struct.

Functions§

from_bytes
Attempts to parse the given bytes into a Bencode object.