1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
//! CJDNS Bencode library. pub use bendy::serde::from_bytes; pub use bendy::serde::to_bytes; pub use bendy::serde::Error; pub use crate::value::{BValue, BencodeError}; mod value; #[cfg(test)] mod tests { use bendy::decoding::FromBencode; #[test] fn test_bencode_leading_zeroes() { /* * Bencode does not allow leading zeroes in encoded integers. * Alas, cjdns' original implementation violates this rule, * and sometimes encodes ints with leading zeroes. * To work around this, bencode library (bendy) should be patched * to support this. * This test checks that we use correct (patched) library. */ assert_eq!(u8::from_bencode("i042e".as_bytes()).ok(), Some(42_u8)); } }