使用 thiserror 定义结构化错误枚举 ProtocolError, 支持通过 context 方法构建错误上下文链。
thiserror
ProtocolError
context
读取 PLC-001 的保持寄存器 40001 失败 → 超时: device=plc-001, timeout=3000ms → 连接失败: 192.168.1.10:502: Connection refused