- /// Failed to decode a public key (ie it's invalid)
- BadPublicKey,
- /// Failed to decode a signature (ie it's invalid)
- BadSignature,
- /// Value expected to be text wasn't decodable as text
- BadText,
+ /// Value was invalid, eg a byte which was supposed to be a bool was something other than a 0
+ /// or 1, a public key/private key/signature was invalid, text wasn't UTF-8, etc
+ InvalidValue,
- DecodeError::BadPublicKey => "Invalid public key in packet",
- DecodeError::BadSignature => "Invalid signature in packet",
- DecodeError::BadText => "Invalid text in packet",
+ DecodeError::InvalidValue => "Nonsense bytes didn't map to the type they were interpreted as",
DecodeError::ShortRead => "Packet extended beyond the provided bytes",
DecodeError::ExtraAddressesPerType => "More than one address of a single type",
DecodeError::BadLengthDescriptor => "A length descriptor in the packet didn't describe the later data correctly",
DecodeError::Io(ref e) => e.description(),
DecodeError::ShortRead => "Packet extended beyond the provided bytes",
DecodeError::ExtraAddressesPerType => "More than one address of a single type",
DecodeError::BadLengthDescriptor => "A length descriptor in the packet didn't describe the later data correctly",
DecodeError::Io(ref e) => e.description(),
sz = cmp::min(data_len, sz);
match String::from_utf8(data[..sz as usize].to_vec()) {
Ok(s) => s,
sz = cmp::min(data_len, sz);
match String::from_utf8(data[..sz as usize].to_vec()) {
Ok(s) => s,