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 {
27 expected: String,
28 actual: String,
29 },
30
31 #[error("Write error: {message} (status: {status})")]
33 WriteError {
34 status: u8,
35 message: String,
36 },
37
38 #[error("Read error: {message} (status: {status})")]
40 ReadError {
41 status: u8,
42 message: String,
43 },
44
45 #[error("Invalid response: {reason}")]
47 InvalidResponse {
48 reason: String,
49 },
50
51 #[error("Operation timed out after {0:?}")]
53 Timeout(Duration),
54
55 #[error("UDT error: {0}")]
57 Udt(String),
58
59 #[error("Connection error: {0}")]
61 Connection(String),
62
63 #[error("String too long: max length is {max_length}, but got {actual_length}")]
65 StringTooLong {
66 max_length: usize,
67 actual_length: usize,
68 },
69
70 #[error("Invalid string: {reason}")]
72 InvalidString {
73 reason: String,
74 },
75
76 #[error("String write failed: {message} (status: {status})")]
78 StringWriteError {
79 status: u8,
80 message: String,
81 },
82
83 #[error("String read failed: {message} (status: {status})")]
85 StringReadError {
86 status: u8,
87 message: String,
88 },
89
90 #[error("Invalid string response: {reason}")]
92 InvalidStringResponse {
93 reason: String,
94 },
95
96 #[error("Tag error: {0}")]
98 Tag(String),
99
100 #[error("Permission denied: {0}")]
102 Permission(String),
103
104 #[error("UTF-8 error: {0}")]
106 Utf8(#[from] std::string::FromUtf8Error),
107
108 #[error("Other error: {0}")]
110 Other(String),
111
112 #[error("Subscription error: {0}")]
114 Subscription(String),
115}