1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! Catalog-driven copy execution with independently prepared check scenarios.
use crate::ContractCheckId;
use crate::ContractFailure;
use crate::FileSystemContract;
use crate::FileSystemContractSuite;
impl FileSystemContractSuite<'_> {
/// Runs every applicable copy check using the catalog's registered order.
///
/// # Returns
///
/// Returns `Ok(())` after all applicable checks complete.
///
/// # Errors
///
/// Returns the first failure produced by a copy check.
pub(super) fn check_copy(&mut self) -> Result<(), ContractFailure> {
for spec in crate::internal::check_catalog::for_contract(FileSystemContract::Copy, false) {
self.check_copy_item(spec.id)?;
}
Ok(())
}
/// Executes only the selected copy requirement.
///
/// # Returns
///
/// Returns `Ok(())` when the selected check completes successfully.
///
/// # Errors
///
/// Returns the selected check's failure, or a failure identifying an
/// unsupported check identifier.
///
/// # Parameters
///
/// - `id`: Registered copy check to execute.
pub(super) fn check_copy_item(&mut self, id: ContractCheckId) -> Result<(), ContractFailure> {
match id {
ContractCheckId::CopyBasic => self.check_basic_copy(id),
ContractCheckId::CopyFallbackOverwriteRejected => self.check_copy_conflict(),
ContractCheckId::CopyNativeNonEmpty => self.check_native_copy_nonempty(),
ContractCheckId::CopyServerSide => self.check_server_side_copy(),
ContractCheckId::CopyAtomicFile | ContractCheckId::CopyDurableFile => self.check_strong_file_copy(id),
ContractCheckId::CopyAtomicTree | ContractCheckId::CopyDurableTree => self.check_strong_tree_copy(id),
_ => Err(ContractFailure::message_only("selected check is not supported by this copy driver").at(id)),
}
}
}