Expand description
Common utilities and types for RCP file operation tools
This crate provides shared functionality used across all RCP tools (rcp, rrm, rlink, rcmp).
It includes core operations (copy, remove, link, compare), progress reporting, metadata preservation, and runtime configuration.
§Core Modules
copy- File copying operations with metadata preservation and error handlingrm- File removal operationslink- Hard-linking operationscmp- File comparison operations (metadata-based)preserve- Metadata preservation settings and operationsprogress- Progress tracking and reportingfilecmp- File metadata comparison utilitiesremote_tracing- Remote tracing support for distributed operations
§Key Types
§RcpdType
Identifies the role of a remote copy daemon:
Source- reads files from source hostDestination- writes files to destination host
§ProgressType
Controls progress reporting display:
Auto- automatically choose based on terminal typeProgressBar- animated progress bar (for interactive terminals)TextUpdates- periodic text updates (for logging/non-interactive)
§Progress Reporting
The crate provides a global progress tracking system accessible via get_progress().
Progress can be displayed in different formats depending on the execution context.
Progress output goes to stderr, while logs go to stdout, allowing users to redirect logs to a file while still viewing interactive progress.
§Runtime Configuration
The run function provides a unified entry point for all RCP tools with support for:
- Progress tracking and reporting
- Logging configuration (quiet/verbose modes)
- Resource limits (max workers, open files, throttling)
- Tokio runtime setup
- Remote tracing integration
§Examples
§Basic Copy Operation
use std::path::Path;
let src = Path::new("/source");
let dst = Path::new("/destination");
let settings = common::copy::Settings {
dereference: false,
fail_early: false,
overwrite: false,
overwrite_compare: Default::default(),
chunk_size: 0,
remote_copy_buffer_size: 0,
filter: None,
dry_run: None,
};
let preserve = common::preserve::preserve_none();
let summary = common::copy(src, dst, &settings, &preserve).await?;
println!("Copied {} files", summary.files_copied);§Metadata Comparison
use std::path::Path;
let src = Path::new("/path1");
let dst = Path::new("/path2");
// output differences to stdout (use false for quiet mode)
let log = common::cmp::LogWriter::new(None, true, common::cmp::OutputFormat::default()).await?;
let settings = common::cmp::Settings {
fail_early: false,
exit_early: false,
expand_missing: false,
compare: Default::default(),
filter: None,
};
let summary = common::cmp(src, dst, &log, &settings).await?;
println!("Comparison complete: {}", summary);Re-exports§
pub use config::DryRunMode;pub use config::DryRunWarnings;pub use config::OutputConfig;pub use config::RuntimeConfig;pub use config::ThrottleConfig;pub use config::TracingConfig;pub use progress::RcpdProgressPrinter;pub use progress::SerializableProgress;
Modules§
- cmp
- config
- Configuration types for runtime and execution settings
- copy
- error_
collector - Collects and deduplicates errors for non-fail-early operation modes.
- filecmp
- filegen
- filter
- Pattern-based file filtering for include/exclude operations
- link
- preserve
- progress
- remote_
tracing - rm
- version
Structs§
- Progress
Settings - Remote
Runtime Stats - runtime stats collected from remote rcpd processes for display at the end of a remote copy
- Runtime
Stats - runtime statistics collected from a process (CPU time, memory usage)
Enums§
Functions§
- cmp
- collect_
runtime_ stats - collects runtime statistics (CPU time, memory) for the current process
- copy
- generate_
debug_ log_ filename - generate_
trace_ filename - Generate a trace filename with identifier, hostname, PID, and timestamp.
- get_
progress - is_
localhost - checks if a host string refers to the local machine.
returns true for
localhost,127.0.0.1,::1,[::1], or the actual hostname - link
- parse_
compare_ settings - parse_
metadata_ cmp_ settings - parse_
preserve_ settings - rm
- run
- set_
remote_ runtime_ stats - stores remote runtime stats for display at the end of a remote copy operation
- validate_
update_ compare_ vs_ preserve - Validates that every attribute checked by –update’s comparison is actually being preserved. Skips size (always preserved via content copy) and ctime (kernel-managed, cannot be set).