Skip to main content

refix_message/value/
error.rs

1use crate::Tag;
2
3/// A field value whose bytes can't be read as the field's declared data type.
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub struct InvalidValue {
6    pub tag: Tag,
7}
8
9impl std::fmt::Display for InvalidValue {
10    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11        write!(f, "invalid value in field {}", self.tag)
12    }
13}
14
15impl std::error::Error for InvalidValue {}
16
17/// A value outside the range of the type it converts to.
18#[derive(Clone, Copy, Debug, Eq, PartialEq)]
19pub struct OutOfRange;
20
21impl std::fmt::Display for OutOfRange {
22    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23        f.write_str("value out of range")
24    }
25}
26
27impl std::error::Error for OutOfRange {}