refactor (Opus 4.5): modularize and split

This commit is contained in:
2025-11-28 21:10:42 +01:00
parent df01131f8d
commit 53c7fe10ba
11 changed files with 3301 additions and 2729 deletions
+43
View File
@@ -0,0 +1,43 @@
//! Error types for peer operations.
/// Custom error types for peer operations.
#[derive(Debug)]
pub enum PeerError {
/// Failed to determine the size of a file.
FileSizeDetermination {
path: String,
source: std::io::Error,
},
/// Game directory has not been configured.
GameDirNotSet,
/// General error wrapper.
Other(eyre::Report),
}
impl std::fmt::Display for PeerError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PeerError::FileSizeDetermination { path, source } => {
write!(f, "Failed to determine file size for {path}: {source}")
}
PeerError::GameDirNotSet => write!(f, "Game directory not set"),
PeerError::Other(err) => write!(f, "General error: {err}"),
}
}
}
impl std::error::Error for PeerError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
PeerError::FileSizeDetermination { source, .. } => Some(source),
PeerError::Other(err) => Some(err.root_cause()),
PeerError::GameDirNotSet => None,
}
}
}
impl From<eyre::Report> for PeerError {
fn from(err: eyre::Report) -> Self {
PeerError::Other(err)
}
}