ArchiveCreator

Struct ArchiveCreator 

Source
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

Source

pub fn new() -> Self

Creates a new ArchiveCreator with default settings.

§Examples
use exarch_core::creation::ArchiveCreator;

let creator = ArchiveCreator::new();
Source

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");
Source

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");
Source

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"]);
Source

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);
Source

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 compression

Sets whether to follow symlinks.

Default: false (symlinks stored as symlinks).

§Examples
use exarch_core::creation::ArchiveCreator;

let creator = ArchiveCreator::new().follow_symlinks(true);
Source

pub fn include_hidden(self, include: bool) -> Self

Sets whether to include hidden files.

Default: false (skip hidden files).

§Examples
use exarch_core::creation::ArchiveCreator;

let creator = ArchiveCreator::new().include_hidden(true);
Source

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/");
Source

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");
Source

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);
Source

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()?;

Trait Implementations§

Source§

impl Debug for ArchiveCreator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ArchiveCreator

Source§

fn default() -> ArchiveCreator

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.