feat: implement production cas v1

This commit is contained in:
2026-06-28 12:39:17 +08:00
parent dd53e3054e
commit b202d7b231
33 changed files with 1082 additions and 447 deletions
+2 -2
View File
@@ -2,10 +2,10 @@
//!
//! 提供客户端发现、备份和集成功能
pub mod integration;
pub mod backup;
pub mod discovery;
pub mod integration;
pub use integration::ClientIntegration;
pub use backup::BackupManager;
pub use discovery::ClientDiscovery;
pub use integration::ClientIntegration;
+5 -1
View File
@@ -114,7 +114,11 @@ pub trait ClientIntegration: Send + Sync {
///
/// - 成功:返回集成结果
/// - 失败:返回错误
async fn rollback(&self, client: &GameClient, backup_id: &str) -> Result<IntegrationResult, String>;
async fn rollback(
&self,
client: &GameClient,
backup_id: &str,
) -> Result<IntegrationResult, String>;
}
#[cfg(test)]
+1 -1
View File
@@ -33,7 +33,7 @@ pub enum AdapterError {
/// 期望的版本
expected: String,
/// 实际的版本
found: String
found: String,
},
/// 备份操作失败
+2 -2
View File
@@ -10,10 +10,10 @@
#![warn(missing_docs)]
#![warn(clippy::all)]
pub mod unity;
pub mod manifest;
pub mod client;
pub mod error;
pub mod manifest;
pub mod unity;
pub use error::{AdapterError, Result};
+2 -2
View File
@@ -2,10 +2,10 @@
//!
//! 提供多种 Manifest 格式的解析支持
pub mod driver;
pub mod addressables;
pub mod driver;
pub mod registry;
pub use driver::{ManifestDriver, GenericManifest, ManifestFormat, ManifestMetadata};
pub use addressables::AddressablesCatalogDriver;
pub use driver::{GenericManifest, ManifestDriver, ManifestFormat, ManifestMetadata};
pub use registry::ManifestDriverRegistry;
+9 -7
View File
@@ -65,14 +65,13 @@ impl ManifestDriver for AddressablesCatalogDriver {
async fn parse(&self, raw_data: &[u8]) -> Result<GenericManifest, String> {
// 解析 JSON
let text = std::str::from_utf8(raw_data)
.map_err(|e| format!("Invalid UTF-8: {}", e))?;
let text = std::str::from_utf8(raw_data).map_err(|e| format!("Invalid UTF-8: {}", e))?;
let json: Value = serde_json::from_str(text)
.map_err(|e| format!("Invalid JSON: {}", e))?;
let json: Value = serde_json::from_str(text).map_err(|e| format!("Invalid JSON: {}", e))?;
// 提取元数据
let locator_id = json.get("m_LocatorId")
let locator_id = json
.get("m_LocatorId")
.and_then(|v| v.as_str())
.map(|s| s.to_string());
@@ -108,7 +107,7 @@ impl ManifestDriver for AddressablesCatalogDriver {
resources.push(ResourceEntry {
path: path.to_string(),
hash: format!("addressable_{}", index), // 临时 Hash
size: 0, // 大小未知
size: 0, // 大小未知
resource_type,
});
}
@@ -180,6 +179,9 @@ mod tests {
let manifest = result.unwrap();
assert_eq!(manifest.format, ManifestFormat::AddressablesCatalog);
assert_eq!(manifest.resources.len(), 3);
assert_eq!(manifest.resources[0].resource_type, ResourceType::AssetBundle);
assert_eq!(
manifest.resources[0].resource_type,
ResourceType::AssetBundle
);
}
}
+3 -3
View File
@@ -3,9 +3,9 @@
//! 提供多个 Unity 版本的 AssetBundle 解析支持
pub mod adapter;
pub mod unity_2021_3;
pub mod registry;
pub mod unity_2021_3;
pub use adapter::{UnityAdapter, VersionRange, RawAssetBundle, ParsedAssetBundle};
pub use unity_2021_3::Unity2021_3Adapter;
pub use adapter::{ParsedAssetBundle, RawAssetBundle, UnityAdapter, VersionRange};
pub use registry::UnityAdapterRegistry;
pub use unity_2021_3::Unity2021_3Adapter;