Skip to main content

file_engine/operations/
mod.rs

1// `pub(crate)` so `sync.rs` (a sibling module of `operations`, not a
2// descendant) can reach `copy::copy_file`/`copy_dir`/etc. — `sync` requires
3// `operations` at the manifest level (§4), so this is always available
4// whenever `sync.rs` is compiled.
5pub(crate) mod copy;
6mod move_op;
7
8pub use copy::CopyBuilder;
9pub use move_op::MoveBuilder;
10
11use std::path::PathBuf;
12
13use crate::engine::FileEngine;
14
15#[cfg(feature = "operations")]
16impl FileEngine {
17    pub fn copy(&self, src: impl Into<PathBuf>, dst: impl Into<PathBuf>) -> CopyBuilder {
18        let options = self.options();
19        CopyBuilder::new(
20            src.into(),
21            dst.into(),
22            options.buffer_size,
23            options.follow_symlinks,
24        )
25    }
26
27    pub fn move_path(&self, src: impl Into<PathBuf>, dst: impl Into<PathBuf>) -> MoveBuilder {
28        let options = self.options();
29        MoveBuilder::new(
30            src.into(),
31            dst.into(),
32            options.buffer_size,
33            options.follow_symlinks,
34        )
35    }
36}