modbus_relay/errors/kinds/
serial_error.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum SerialErrorKind {
3    OpenFailed,
4    ReadFailed,
5    WriteFailed,
6    ConfigurationFailed,
7    Disconnected,
8    BufferOverflow,
9    ParityError,
10    FramingError,
11}
12
13impl std::fmt::Display for SerialErrorKind {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        match self {
16            Self::OpenFailed => write!(f, "Failed to open port"),
17            Self::ReadFailed => write!(f, "Failed to read from port"),
18            Self::WriteFailed => write!(f, "Failed to write to port"),
19            Self::ConfigurationFailed => write!(f, "Failed to configure port"),
20            Self::Disconnected => write!(f, "Port disconnected"),
21            Self::BufferOverflow => write!(f, "Buffer overflow"),
22            Self::ParityError => write!(f, "Parity error"),
23            Self::FramingError => write!(f, "Framing error"),
24        }
25    }
26}