- 添加 README.md 项目文档 - 更新 .gitignore 排除 JE-Skin/、eskin-finger-sdk/ 及构建产物 - 从 git 跟踪中移除 JE-Skin 和 eskin-finger-sdk Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
52 lines
1.5 KiB
Rust
52 lines
1.5 KiB
Rust
use std::fmt;
|
|
|
|
#[derive(Debug)]
|
|
pub enum SerialError {
|
|
OpenError,
|
|
CloseError,
|
|
ScanError,
|
|
InvalidConfig,
|
|
AlreadyConnected,
|
|
StateError,
|
|
NoRecordedData,
|
|
}
|
|
|
|
impl fmt::Display for SerialError {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match self {
|
|
SerialError::OpenError => write!(f, "Opening Error"),
|
|
SerialError::CloseError => write!(f, "Closing Error"),
|
|
SerialError::ScanError => write!(f, "Scan Error"),
|
|
SerialError::InvalidConfig => write!(f, "Invalid Config"),
|
|
SerialError::AlreadyConnected => write!(f, "Already Connected"),
|
|
SerialError::StateError => write!(f, "State Error"),
|
|
SerialError::NoRecordedData => write!(f, "No Recorded Data"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for SerialError {}
|
|
|
|
#[derive(Debug)]
|
|
pub enum CodecError {
|
|
InvalidHeader,
|
|
InvalidTail,
|
|
InvalidLength,
|
|
InvalidFrameType,
|
|
PayloadTooLarge,
|
|
}
|
|
|
|
impl fmt::Display for CodecError {
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
match self {
|
|
CodecError::InvalidHeader => write!(f, "Invalid Header"),
|
|
CodecError::InvalidTail => write!(f, "Invalid Tail"),
|
|
CodecError::InvalidLength => write!(f, "Invalid Length"),
|
|
CodecError::InvalidFrameType => write!(f, "Invalid Frame Type"),
|
|
CodecError::PayloadTooLarge => write!(f, "Payload too large"),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl std::error::Error for CodecError {}
|