rust_ethernet_ip/
error.rs1use std::io;
3use std::time::Duration;
4use thiserror::Error;
5
6pub type Result<T> = std::result::Result<T, EtherNetIpError>;
8
9#[derive(Debug, Error)]
11pub enum EtherNetIpError {
12 #[error("IO error: {0}")]
14 Io(#[from] io::Error),
15
16 #[error("Protocol error: {0}")]
18 Protocol(String),
19
20 #[error("Tag not found: {0}")]
22 TagNotFound(String),
23
24 #[error("Data type mismatch: expected {expected}, got {actual}")]
26 DataTypeMismatch { expected: String, actual: String },
27
28 #[error("Write error: {message} (status: {status})")]
30 WriteError { status: u8, message: String },
31
32 #[error("Read error: {message} (status: {status})")]
34 ReadError { status: u8, message: String },
35
36 #[error("Invalid response: {reason}")]
38 InvalidResponse { reason: String },
39
40 #[error("Operation timed out after {0:?}")]
42 Timeout(Duration),
43
44 #[error("UDT error: {0}")]
46 Udt(String),
47
48 #[error("Connection error: {0}")]
50 Connection(String),
51
52 #[error("String too long: max length is {max_length}, but got {actual_length}")]
54 StringTooLong {
55 max_length: usize,
56 actual_length: usize,
57 },
58
59 #[error("Invalid string: {reason}")]
61 InvalidString { reason: String },
62
63 #[error("String write failed: {message} (status: {status})")]
65 StringWriteError { status: u8, message: String },
66
67 #[error("String read failed: {message} (status: {status})")]
69 StringReadError { status: u8, message: String },
70
71 #[error("Invalid string response: {reason}")]
73 InvalidStringResponse { reason: String },
74
75 #[error("Tag error: {0}")]
77 Tag(String),
78
79 #[error("Permission denied: {0}")]
81 Permission(String),
82
83 #[error("UTF-8 error: {0}")]
85 Utf8(#[from] std::string::FromUtf8Error),
86
87 #[error("Other error: {0}")]
89 Other(String),
90
91 #[error("Subscription error: {0}")]
93 Subscription(String),
94}