Throw error for unexpected input length for Fingerprint.

This commit is contained in:
Heiko Schaefer 2021-09-07 15:00:22 +02:00
parent 6cfe340d2b
commit 891b57df06

View file

@ -28,11 +28,13 @@ impl TryFrom<&[u8]> for Fingerprint {
input.len()
);
// FIXME: return error
assert_eq!(input.len(), 20);
if input.len() == 20 {
let array: [u8; 20] = input.try_into().unwrap();
Ok(array.into())
} else {
Err(anyhow!("Unexpected fingerprint length {}", input.len())
.into())
}
}
}