Skip to main content

qubit_fs/spi/request/
copy_request.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// facade.
9//! Validated copy request.
10
11use crate::path::Path;
12use crate::spi::ResolvedCopyOptions;
13
14/// A facade-created copy request.
15///
16/// # Examples
17///
18/// ```rust
19/// use qubit_fs::copy::CopyOptions;
20/// use qubit_fs::path::Path;
21/// use qubit_fs::spi::CopyRequest;
22///
23/// let source = Path::parse("/source")?;
24/// let target = Path::parse("/target")?;
25/// assert!(std::any::type_name::<CopyRequest<'_>>().contains("CopyRequest"));
26/// assert_ne!(source.as_str(), target.as_str());
27/// let _ = CopyOptions::default();
28/// # Ok::<(), qubit_fs::FsError>(())
29/// ```
30pub struct CopyRequest<'a> {
31    /// Validated source path.
32    source: &'a Path,
33    /// Validated destination path.
34    target: &'a Path,
35    /// Facade-resolved copy policy.
36    options: ResolvedCopyOptions,
37}
38
39impl<'a> CopyRequest<'a> {
40    /// Creates this request inside the facade boundary.
41    ///
42    /// # Parameters
43    /// - `source`: Validated source path.
44    /// - `target`: Validated destination path.
45    /// - `options`: Facade-resolved copy options.
46    ///
47    /// # Returns
48    /// A provider copy request borrowing both paths.
49    #[allow(dead_code)]
50    #[inline]
51    pub(crate) const fn new(source: &'a Path, target: &'a Path, options: ResolvedCopyOptions) -> Self {
52        Self {
53            source,
54            target,
55            options,
56        }
57    }
58
59    /// Returns the source path.
60    ///
61    /// # Returns
62    /// The validated source path.
63    #[inline]
64    #[must_use]
65    pub const fn source(&self) -> &'a Path {
66        self.source
67    }
68
69    /// Returns the target path.
70    ///
71    /// # Returns
72    /// The validated destination path.
73    #[inline]
74    #[must_use]
75    pub const fn target(&self) -> &'a Path {
76        self.target
77    }
78
79    /// Returns resolved options.
80    ///
81    /// # Returns
82    /// The immutable facade-resolved copy options.
83    #[inline]
84    #[must_use]
85    pub const fn options(&self) -> &ResolvedCopyOptions {
86        &self.options
87    }
88}