mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-09-18 13:54:53 +08:00
feat(assetbundle): 完善官方资源解析与双目录发布
This commit is contained in:
@@ -1,26 +1,52 @@
|
||||
//! AssetBundle 错误类型定义
|
||||
//! AssetBundle error types.
|
||||
|
||||
use thiserror::Error;
|
||||
|
||||
/// AssetBundle 错误类型
|
||||
/// AssetBundle parser error.
|
||||
#[derive(Error, Debug)]
|
||||
pub enum AssetBundleError {
|
||||
/// IO 错误
|
||||
/// I/O error.
|
||||
#[error("IO error: {0}")]
|
||||
Io(#[from] std::io::Error),
|
||||
|
||||
/// 解析错误
|
||||
/// Parser reached malformed data while reading a named field.
|
||||
#[error("Parse error at offset {offset} while reading {field}: {message}")]
|
||||
ParseField {
|
||||
/// Field or structure name being read.
|
||||
field: String,
|
||||
/// Byte offset where parsing failed.
|
||||
offset: usize,
|
||||
/// Human-readable diagnostic.
|
||||
message: String,
|
||||
},
|
||||
|
||||
/// General parser error.
|
||||
#[error("Parse error: {0}")]
|
||||
Parse(String),
|
||||
|
||||
/// 不支持的格式
|
||||
/// Unsupported format or compression mode.
|
||||
#[error("Unsupported format: {0}")]
|
||||
UnsupportedFormat(String),
|
||||
|
||||
/// 其他错误
|
||||
/// Other error.
|
||||
#[error(transparent)]
|
||||
Other(#[from] anyhow::Error),
|
||||
}
|
||||
|
||||
/// AssetBundle Result 类型
|
||||
impl AssetBundleError {
|
||||
/// Creates a field-scoped parser error with byte offset context.
|
||||
pub fn parse_field(
|
||||
field: impl Into<String>,
|
||||
offset: usize,
|
||||
message: impl Into<String>,
|
||||
) -> Self {
|
||||
Self::ParseField {
|
||||
field: field.into(),
|
||||
offset,
|
||||
message: message.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// AssetBundle result type.
|
||||
pub type Result<T> = std::result::Result<T, AssetBundleError>;
|
||||
|
||||
Reference in New Issue
Block a user