pub struct ArchiveCreator { /* private fields */ }Expand description
Builder for creating archives with fluent API.
Provides a convenient, type-safe interface for configuring and creating archives with various compression formats and security options.
§Examples
use exarch_core::creation::ArchiveCreator;
let report = ArchiveCreator::new()
.output("backup.tar.gz")
.add_source("src/")
.add_source("Cargo.toml")
.compression_level(9)
.create()?;
println!("Created archive with {} files", report.files_added);Implementations§
Source§impl ArchiveCreator
impl ArchiveCreator
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ArchiveCreator with default settings.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new();Sourcepub fn output<P: AsRef<Path>>(self, path: P) -> Self
pub fn output<P: AsRef<Path>>(self, path: P) -> Self
Sets the output archive path.
The archive format is auto-detected from the file extension
unless explicitly set via format().
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().output("backup.tar.gz");Sourcepub fn add_source<P: AsRef<Path>>(self, path: P) -> Self
pub fn add_source<P: AsRef<Path>>(self, path: P) -> Self
Adds a source file or directory.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new()
.add_source("src/")
.add_source("Cargo.toml");Sourcepub fn sources<P: AsRef<Path>>(self, paths: &[P]) -> Self
pub fn sources<P: AsRef<Path>>(self, paths: &[P]) -> Self
Adds multiple source files or directories.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().sources(&["src/", "Cargo.toml", "README.md"]);Sourcepub fn config(self, config: CreationConfig) -> Self
pub fn config(self, config: CreationConfig) -> Self
Sets the full configuration.
§Examples
use exarch_core::creation::ArchiveCreator;
use exarch_core::creation::CreationConfig;
let config = CreationConfig::default().with_follow_symlinks(true);
let creator = ArchiveCreator::new().config(config);Sourcepub fn compression_level(self, level: u8) -> Self
pub fn compression_level(self, level: u8) -> Self
Sets the compression level (1-9).
Higher values provide better compression but slower speed.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().compression_level(9); // Maximum compressionSourcepub fn follow_symlinks(self, follow: bool) -> Self
pub fn follow_symlinks(self, follow: bool) -> Self
Sets whether to follow symlinks.
Default: false (symlinks stored as symlinks).
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().follow_symlinks(true);Sets whether to include hidden files.
Default: false (skip hidden files).
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().include_hidden(true);Sourcepub fn exclude<S: Into<String>>(self, pattern: S) -> Self
pub fn exclude<S: Into<String>>(self, pattern: S) -> Self
Adds an exclude pattern.
Files matching this pattern will be skipped.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().exclude("*.log").exclude("target/");Sourcepub fn strip_prefix<P: AsRef<Path>>(self, prefix: P) -> Self
pub fn strip_prefix<P: AsRef<Path>>(self, prefix: P) -> Self
Sets the strip prefix for archive paths.
If set, this prefix will be removed from all entry paths in the archive.
§Examples
use exarch_core::creation::ArchiveCreator;
let creator = ArchiveCreator::new().strip_prefix("/base/path");Sourcepub fn format(self, format: ArchiveType) -> Self
pub fn format(self, format: ArchiveType) -> Self
Sets explicit archive format.
If not set, format is auto-detected from output file extension.
§Examples
use exarch_core::creation::ArchiveCreator;
use exarch_core::formats::detect::ArchiveType;
let creator = ArchiveCreator::new().format(ArchiveType::TarGz);Sourcepub fn create(self) -> Result<CreationReport>
pub fn create(self) -> Result<CreationReport>
Creates the archive.
§Errors
Returns an error if:
- Output path not set
- No sources provided
- Source files don’t exist
- I/O errors during creation
- Invalid configuration (e.g., invalid compression level)
§Examples
use exarch_core::creation::ArchiveCreator;
let report = ArchiveCreator::new()
.output("backup.tar.gz")
.add_source("src/")
.create()?;