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 28 29 30 31 32 33 34 35 36
use core::fmt;
/// Errors returned by the BLE stack.
#[derive(Debug, PartialEq, Eq, defmt::Format)]
#[non_exhaustive]
pub enum Error {
/// Packet specified an invalid length value or was too short.
///
/// This indicates a protocol violation, so the connection should
/// considered lost (if one is currently established).
InvalidLength,
/// Invalid value supplied for field.
InvalidValue,
/// Unexpectedly reached EOF while reading or writing data.
///
/// This is returned when the application tries to fit too much data into a
/// PDU or other fixed-size buffer, and also when reaching EOF prematurely
/// while reading data from a buffer.
Eof,
/// Parsing didn't consume the entire buffer.
IncompleteParse,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Error::InvalidLength => "invalid length value specified",
Error::InvalidValue => "invalid value for field",
Error::Eof => "end of buffer",
Error::IncompleteParse => "excess data in buffer",
})
}
}