Skip to main content

check_bencode_structure

Function check_bencode_structure 

Source
pub fn check_bencode_structure(data: &[u8]) -> Result<(), BencodeStructureError>
Expand description

Walk one bencode value iteratively, refusing anything nested deeper than MAX_BENCODE_DEPTH.

Call this on every byte string that arrives from the network before handing it to serde_bencode. It is O(n), allocates nothing, and never recurses.