substrate_data/wire/binary/decode_error.rs
1//! [`DecodeError`]: malformed binary data, and where.
2
3use std::fmt;
4
5/// Malformed binary data.
6#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct DecodeError {
8 /// What's wrong.
9 pub message: String,
10 /// The byte it was found at.
11 pub offset: usize,
12}
13
14impl fmt::Display for DecodeError {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 write!(f, "byte {}: {}", self.offset, self.message)
17 }
18}
19
20impl std::error::Error for DecodeError {}