feat(assetbundle): 完成已验证结构的重建发布闭环
bat-rust / Build and test Rust (push) Canceled after 0s
bat-rust / Build and test Go API (push) Canceled after 0s

This commit is contained in:
2026-09-10 00:46:48 +08:00
parent 68c6c91b1e
commit 69b6e36bf0
21 changed files with 1588 additions and 101 deletions
+28
View File
@@ -1088,6 +1088,34 @@ impl UnitySerializedFile {
}
}
/// Returns the raw payload bytes for one object table entry.
///
/// The returned slice is still owned by the parsed serialized file. It is
/// useful to compare untouched objects across a variable-length rebuild.
pub fn object_bytes(&self, object: &UnitySerializedObject) -> Result<&[u8]> {
let object_start = self
.data_offset
.checked_add(usize::try_from(object.byte_start).map_err(|_| {
AssetBundleError::Parse(format!(
"Unity object path_id {} byte_start does not fit usize",
object.path_id
))
})?)
.ok_or_else(|| AssetBundleError::Parse("Unity object offset overflow".to_string()))?;
let object_end = object_start
.checked_add(object.byte_size as usize)
.ok_or_else(|| AssetBundleError::Parse("Unity object size overflow".to_string()))?;
self.raw_data.get(object_start..object_end).ok_or_else(|| {
AssetBundleError::Parse(format!(
"Unity object path_id {} byte range {}..{} exceeds file size {}",
object.path_id,
object_start,
object_end,
self.raw_data.len()
))
})
}
fn rewrite_object_payload(
&self,
target_index: usize,