Skip to main content

qubit_fs_testkit/
async_copy_fixture_case.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//! Provider-prepared asynchronous copy fixture cases.
9
10use qubit_fs::copy::CopyOptions;
11use qubit_fs::path::Path;
12
13/// Provider-prepared asynchronous copy request used for cancellation probing.
14///
15/// # Examples
16///
17/// ```
18/// use qubit_fs::copy::CopyOptions;
19/// use qubit_fs::path::Path;
20/// use qubit_fs_testkit::AsyncCopyFixtureCase;
21///
22/// let source = Path::parse("/source")?;
23/// let target = Path::parse("/target")?;
24/// let case = AsyncCopyFixtureCase::new(source, target, CopyOptions::file());
25/// assert_eq!(case.target(), &Path::parse("/target")?);
26/// # Ok::<(), qubit_fs::error::FsError>(())
27/// ```
28#[must_use]
29#[derive(Clone, Debug)]
30pub struct AsyncCopyFixtureCase {
31    /// Source path passed to the copy operation.
32    source: Path,
33    /// Destination path passed to the copy operation.
34    target: Path,
35    /// Options governing the probed copy operation.
36    options: CopyOptions,
37}
38
39impl AsyncCopyFixtureCase {
40    /// Creates a cancellation probe request from owned copy arguments.
41    ///
42    /// # Parameters
43    ///
44    /// * `source` - Source path passed to the copy operation.
45    /// * `target` - Destination path passed to the copy operation.
46    /// * `options` - Options governing the copy operation.
47    ///
48    /// # Returns
49    ///
50    /// A prepared request containing the supplied arguments.
51    #[inline]
52    pub fn new(source: Path, target: Path, options: CopyOptions) -> Self {
53        Self {
54            source,
55            target,
56            options,
57        }
58    }
59
60    /// Returns the source path without transferring ownership.
61    ///
62    /// # Returns
63    ///
64    /// The prepared source path.
65    #[inline]
66    #[must_use]
67    pub const fn source(&self) -> &Path {
68        &self.source
69    }
70
71    /// Returns the target path without transferring ownership.
72    ///
73    /// # Returns
74    ///
75    /// The prepared destination path.
76    #[inline]
77    #[must_use]
78    pub const fn target(&self) -> &Path {
79        &self.target
80    }
81
82    /// Returns the copy options without transferring ownership.
83    ///
84    /// # Returns
85    ///
86    /// The prepared copy options.
87    #[inline]
88    #[must_use]
89    pub const fn options(&self) -> &CopyOptions {
90        &self.options
91    }
92
93    /// Decomposes the prepared request into owned parts.
94    ///
95    /// # Returns
96    ///
97    /// The source path, destination path, and copy options in that order.
98    #[inline]
99    #[must_use]
100    pub fn into_parts(self) -> (Path, Path, CopyOptions) {
101        (self.source, self.target, self.options)
102    }
103}