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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
*
* Copyright (c) 2026 Haixing Hu.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0.
*
******************************************************************************/
//! Copy operation options and policy types.
use qubit_metadata::MetadataFilter;
use crate::{
CopyConflictPolicy,
CopyMode,
MetadataPreservePolicy,
ProgressPolicy,
ServerSidePreference,
};
/// Options controlling file, object, or tree copy operations.
#[derive(Clone, Debug, PartialEq)]
pub struct CopyOptions {
/// Copy source interpretation mode.
pub mode: CopyMode,
/// Destination conflict policy.
pub conflict: CopyConflictPolicy,
/// Metadata preservation policy.
pub preserve_metadata: MetadataPreservePolicy,
/// Server-side copy preference.
pub server_side: ServerSidePreference,
/// Whether symbolic links should be followed.
pub follow_symlinks: bool,
/// Whether missing destination parents should be created.
pub create_parent: bool,
/// Whether tree copy should continue after per-entry failures.
pub continue_on_error: bool,
/// Optional metadata filter for tree copy.
pub filter: Option<MetadataFilter>,
/// Progress collection policy.
pub progress: ProgressPolicy,
}
impl CopyOptions {
/// Creates options for copying one file-like resource.
///
/// # Returns
/// Copy options with `mode` set to [`CopyMode::File`].
#[inline]
#[must_use]
pub fn file() -> Self {
Self {
mode: CopyMode::File,
..Self::default()
}
}
/// Creates options for copying a resource tree.
///
/// # Returns
/// Copy options with `mode` set to [`CopyMode::Tree`].
#[inline]
#[must_use]
pub fn tree() -> Self {
Self {
mode: CopyMode::Tree,
..Self::default()
}
}
}
impl Default for CopyOptions {
#[inline]
fn default() -> Self {
Self {
mode: CopyMode::Auto,
conflict: CopyConflictPolicy::Fail,
preserve_metadata: MetadataPreservePolicy::Portable,
server_side: ServerSidePreference::Prefer,
follow_symlinks: false,
create_parent: false,
continue_on_error: false,
filter: None,
progress: ProgressPolicy::CountOnly,
}
}
}