use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, clap::ValueEnum, Serialize, Deserialize)]
pub enum DryRunMode {
#[value(name = "brief")]
Brief,
#[value(name = "all")]
All,
#[value(name = "explain")]
Explain,
}
#[derive(Debug, Clone, Copy, Default)]
pub struct RuntimeConfig {
pub max_workers: usize,
pub max_blocking_threads: usize,
}
#[derive(Debug, Clone, Copy, Default)]
pub struct ThrottleConfig {
pub max_open_files: Option<usize>,
pub ops_throttle: usize,
pub iops_throttle: usize,
pub chunk_size: u64,
}
impl ThrottleConfig {
pub fn validate(&self) -> Result<(), String> {
if self.iops_throttle > 0 && self.chunk_size == 0 {
return Err("chunk_size must be specified when using iops_throttle".to_string());
}
Ok(())
}
}
#[derive(Debug, Clone, Copy, Default)]
pub struct OutputConfig {
pub quiet: bool,
pub verbose: u8,
pub print_summary: bool,
pub suppress_runtime_stats: bool,
}
pub struct DryRunWarnings {
warnings: Vec<String>,
}
impl DryRunWarnings {
#[must_use]
pub fn new(
has_progress: bool,
has_summary: bool,
verbose: u8,
has_overwrite: bool,
has_filters: bool,
has_destination: bool,
has_ignore_existing: bool,
) -> Self {
let mut warnings = Vec::new();
if has_progress {
warnings.push("dry-run: --progress was ignored".to_string());
}
if has_summary && verbose == 0 {
warnings.push("dry-run: --summary was ignored".to_string());
}
if has_overwrite {
warnings.push(
"dry-run: --overwrite was ignored; dry-run does not check destination state"
.to_string(),
);
}
if !has_filters && !has_ignore_existing {
if has_destination {
warnings.push(
"dry-run: no filtering specified. dry-run is primarily useful to preview \
--include/--exclude/--filter-file filtering; it does not check whether \
files already exist at the destination."
.to_string(),
);
} else {
warnings.push(
"dry-run: no filtering specified. dry-run is primarily useful to preview \
--include/--exclude/--filter-file filtering."
.to_string(),
);
}
}
Self { warnings }
}
pub fn print(&self) {
for warning in &self.warnings {
eprintln!("{warning}");
}
}
}
#[derive(Debug)]
pub struct TracingConfig {
pub remote_layer: Option<crate::remote_tracing::RemoteTracingLayer>,
pub debug_log_file: Option<String>,
pub chrome_trace_prefix: Option<String>,
pub flamegraph_prefix: Option<String>,
pub trace_identifier: String,
pub profile_level: Option<String>,
pub tokio_console: bool,
pub tokio_console_port: Option<u16>,
}
impl Default for TracingConfig {
fn default() -> Self {
Self {
remote_layer: None,
debug_log_file: None,
chrome_trace_prefix: None,
flamegraph_prefix: None,
trace_identifier: "unknown".to_string(),
profile_level: None,
tokio_console: false,
tokio_console_port: None,
}
}
}