stun_coder/attribute/
errors.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum AttributeDecodeError {
6 #[error("Error reading field value.")]
8 ReadFailure(#[from] std::io::Error),
9 #[error("Failed to convert byte sequence into a UTF-8 string.")]
11 InvalidString(#[from] std::string::FromUtf8Error),
12 #[error("Not enough data.")]
14 InsufficientData(),
15 #[error("Invalid field value: {0}.")]
17 InvalidValue(u128),
18 #[error("Unrecognized attribute type value: {attr_type:?}.")]
20 UnrecognizedAttributeType {
21 attr_type: u16,
23 },
24}
25
26#[derive(Error, Debug)]
28pub enum AttributeEncodeError {
29 #[error("Error writing field value.")]
31 WriteFailure(#[from] std::io::Error),
32 #[error("UTF-8 value too big. Limit: {limit}, current length: {length}.")]
35 Utf8ValueTooBig {
36 limit: usize,
38 length: usize,
40 },
41}