diff --git a/crates/bat-patch/src/binary.rs b/crates/bat-patch/src/binary.rs index 3acf3e4..53c66a8 100644 --- a/crates/bat-patch/src/binary.rs +++ b/crates/bat-patch/src/binary.rs @@ -1,6 +1,22 @@ //! Binary Patch 模块占位 -/// Binary Patch 应用(待实现) +/// Binary Patch 应用(尚未实现)。 +/// +/// 返回 [`crate::PatchError::ApplyFailed`] 而非空结果,避免调用方把未实现的 +/// 占位当成一次成功的补丁应用。 pub fn apply_patch(_old: &[u8], _patch: &[u8]) -> crate::Result> { - Ok(Vec::new()) + Err(crate::PatchError::ApplyFailed( + "binary patch 尚未实现".to_string(), + )) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn apply_patch_reports_not_implemented() { + let error = apply_patch(b"old", b"patch").unwrap_err(); + assert!(matches!(error, crate::PatchError::ApplyFailed(_))); + } } diff --git a/crates/bat-patch/src/json.rs b/crates/bat-patch/src/json.rs index ccac569..8088a8d 100644 --- a/crates/bat-patch/src/json.rs +++ b/crates/bat-patch/src/json.rs @@ -1,6 +1,22 @@ //! JSON Patch 模块占位 -/// JSON Patch 应用(待实现) +/// JSON Patch 应用(尚未实现)。 +/// +/// 返回 [`crate::PatchError::ApplyFailed`] 而非空字符串,避免调用方把未实现的 +/// 占位当成一次成功的补丁应用。 pub fn apply_json_patch(_doc: &str, _patch: &str) -> crate::Result { - Ok(String::new()) + Err(crate::PatchError::ApplyFailed( + "json patch 尚未实现".to_string(), + )) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn apply_json_patch_reports_not_implemented() { + let error = apply_json_patch("{}", "[]").unwrap_err(); + assert!(matches!(error, crate::PatchError::ApplyFailed(_))); + } }