From 0c3c48bf746222280020adb0b85885369e70112e Mon Sep 17 00:00:00 2001 From: Bryant Luk Date: Sat, 30 Jul 2022 12:27:25 -0500 Subject: [PATCH] Clarify a few ErrorKind comments --- src/error.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/error.rs b/src/error.rs index a608f53..fd8461f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -157,32 +157,30 @@ pub enum ErrorKind { /// When deserializing an integer, the integer contained non-number characters. InvalidInteger, /// When deserializing a dictionary, the dictionary was not encoded correctly. - /// - /// Usually, the error is because a dictionary was not a byte string. InvalidDict, /// When deserializing a list, the list was not encoded correctly. - /// - /// Usually the error is because an invalid encoded item in the list was found. InvalidList, #[cfg(feature = "std")] /// An I/O error. Io(std::io::Error), /// When deserializing, a dictionary key was found which was not a byte string. KeyMustBeAByteStr, - /// A dictionary key was serialized but did not have a value for the key. + /// A dictionary key was serialized but a call to serialize the key's value + /// was never made after. KeyWithoutValue, /// General serialization error. Serialize(String), /// Unparsed trailing data was detected TrailingData, - /// An unsupported type was used. + /// An unsupported type was used during serialization. /// - /// Usually the error is due to using unsupported types for keys (e.g. using - /// an integer type instead of a ByteStr). - UnsupportedType, - /// A dictionary did not have a key but had a value. + /// Bencode only supports integers, byte strings, lists, and dictionaries. + /// Types like `bool`, `f64`, and enums are not supported in general. /// - /// Should never occur. + /// Dictionaries only support byte strings as keys. + UnsupportedType, + /// A dictionary value was serialized but a call to serialize the key was + /// never made beforehand. ValueWithoutKey, }