Skip to main content

qubit_fs/copy/
copy_assessment.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8
9//! Static copy execution assessment.
10
11use super::CopyExecutionRoute;
12use super::FallbackRejection;
13
14/// Result of no-I/O copy route analysis.
15///
16/// The assessment is derived from the cached provider snapshot and does not
17/// contact the provider. Execution may still fail after this assessment.
18///
19/// # Examples
20///
21/// ```rust
22/// # fn main() -> Result<(), qubit_fs::FsError> {
23/// use qubit_fs::Path;
24/// use qubit_fs::copy::CopyExecutionRoute;
25/// use qubit_fs::copy::CopyOptions;
26/// # mod support { include!(concat!(env!("CARGO_MANIFEST_DIR"), "/tests/common/rustdoc_support.rs")); }
27/// let fs = support::rustdoc_provider::filesystem();
28/// let assessment = fs.assess_copy(&Path::parse("/report")?, &Path::parse("/copy")?, &CopyOptions::default())?;
29/// assert_eq!(assessment.route(), CopyExecutionRoute::StreamOnly);
30/// assert_eq!(assessment.fallback_rejection(), None);
31/// # Ok(())
32/// # }
33/// ```
34#[derive(Clone, Copy, Debug, Eq, PartialEq)]
35pub struct CopyAssessment {
36    route: CopyExecutionRoute,
37    fallback_rejection: Option<FallbackRejection>,
38}
39
40impl CopyAssessment {
41    /// Creates an assessment inside the facade.
42    #[inline]
43    pub(crate) const fn new(route: CopyExecutionRoute, fallback_rejection: Option<FallbackRejection>) -> Self {
44        Self {
45            route,
46            fallback_rejection,
47        }
48    }
49
50    /// Returns the possible execution route.
51    #[inline]
52    #[must_use]
53    pub const fn route(self) -> CopyExecutionRoute {
54        self.route
55    }
56
57    /// Returns the first static fallback rejection, if any.
58    #[inline]
59    #[must_use]
60    pub const fn fallback_rejection(self) -> Option<FallbackRejection> {
61        self.fallback_rejection
62    }
63}