Skip to main content

CreationConfig

Struct CreationConfig 

Source
pub struct CreationConfig<State = Unvalidated> { /* private fields */ }
Expand description

Configuration for archive creation operations.

Controls how archives are created from filesystem sources, including security options, compression settings, and file filtering.

§Examples

use exarch_core::creation::CreationConfig;

// Use secure defaults
let config = CreationConfig::default();

// Customize for specific needs
let custom = CreationConfig::default()
    .with_follow_symlinks(true)
    .with_compression_level(9)?;

§Typestate

CreationConfig carries a phantom State type parameter — Unvalidated (the default) or Validated — that tracks whether validate has been called. Builder methods are only available in the Unvalidated state; the low-level creation::tar::* / creation::zip::* functions and FormatCreator::create require CreationConfig<Validated>. This makes skipping validation a compile error instead of a runtime gap — a forged or hand-mutated compression_level can no longer reach the flate2/xz2 backends, which panic on out-of-range values instead of returning an error.

§Sealing

Fields are private and reachable only through Deref<Target = CreationConfigFields>, so config.compression_level continues to work as plain field access for both states. DerefMut is implemented only for CreationConfig<Unvalidated>, so a CreationConfig<Validated>’s fields cannot be reassigned after the fact — the only way to produce one is validate itself, and it stays that way for its entire lifetime.

Implementations§

Source§

impl CreationConfig<Unvalidated>

Source

pub fn new() -> Self

Creates a new CreationConfig with default settings.

Sets whether to follow symlinks.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_follow_symlinks(true);
assert!(config.follow_symlinks);
Source

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

Sets whether to include hidden files.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_include_hidden(true);
assert!(config.include_hidden);
Source

pub fn with_max_file_size(self, max_size: Option<u64>) -> Self

Sets the maximum file size.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_max_file_size(Some(1024 * 1024));
assert_eq!(config.max_file_size, Some(1024 * 1024));
Source

pub fn with_exclude_patterns(self, patterns: Vec<String>) -> Self

Sets the exclude patterns.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_exclude_patterns(vec!["*.log".to_string()]);
assert_eq!(config.exclude_patterns, vec!["*.log".to_string()]);
Source

pub fn with_strip_prefix(self, prefix: Option<PathBuf>) -> Self

Sets the strip prefix.

§Examples
use exarch_core::creation::CreationConfig;
use std::path::PathBuf;

let config = CreationConfig::default().with_strip_prefix(Some(PathBuf::from("/base")));
assert_eq!(config.strip_prefix, Some(PathBuf::from("/base")));
Source

pub fn with_compression_level(self, level: u8) -> Result<Self>

Sets the compression level.

§Errors

Returns ArchiveError::InvalidCompressionLevel if level is not in the range 1–9.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_compression_level(9)?;
assert_eq!(config.compression_level, Some(9));
Source

pub fn with_preserve_permissions(self, preserve: bool) -> Self

Sets whether to preserve permissions.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default().with_preserve_permissions(false);
assert!(!config.preserve_permissions);
Source

pub fn with_format(self, format: Option<ArchiveType>) -> Self

Sets the archive format.

§Examples
use exarch_core::creation::CreationConfig;
use exarch_core::formats::detect::ArchiveType;

let config = CreationConfig::default().with_format(Some(ArchiveType::TarGz));
assert_eq!(config.format, Some(ArchiveType::TarGz));
Source

pub fn validate(self) -> Result<CreationConfig<Validated>>

Validates the configuration, transitioning to the Validated typestate on success.

Consumes self: the only way to obtain a CreationConfig<Validated>, which is what the low-level creation::tar::* / creation::zip::* functions and FormatCreator::create require. Once returned, the Validated config’s fields can no longer be reassigned (see the “Sealing” section on the type-level docs), so this check can never be silently invalidated afterward.

§Errors

Returns ArchiveError::InvalidCompressionLevel if compression_level is set but not in the range 1–9.

§Examples
use exarch_core::creation::CreationConfig;

let config = CreationConfig::default();
assert!(config.validate().is_ok());

Trait Implementations§

Source§

impl<State: Clone> Clone for CreationConfig<State>

Source§

fn clone(&self) -> CreationConfig<State>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<State: Debug> Debug for CreationConfig<State>

Source§

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

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

impl Default for CreationConfig<Unvalidated>

Source§

fn default() -> Self

Creates a CreationConfig with secure default settings.

Default values:

  • follow_symlinks: false
  • include_hidden: false
  • max_file_size: None
  • exclude_patterns: [".git", ".DS_Store", "*.tmp"]
  • strip_prefix: None
  • compression_level: Some(6)
  • preserve_permissions: true
  • format: None
Source§

impl<State> Deref for CreationConfig<State>

Source§

type Target = CreationConfigFields

The resulting type after dereferencing.
Source§

fn deref(&self) -> &CreationConfigFields

Dereferences the value.
Source§

impl DerefMut for CreationConfig<Unvalidated>

Only Unvalidated configs are mutable — see the “Sealing” section on CreationConfig’s type-level docs for why this is the crux of the typestate guarantee.

Source§

fn deref_mut(&mut self) -> &mut CreationConfigFields

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<State> Freeze for CreationConfig<State>

§

impl<State> RefUnwindSafe for CreationConfig<State>
where State: RefUnwindSafe,

§

impl<State> Send for CreationConfig<State>
where State: Send,

§

impl<State> Sync for CreationConfig<State>
where State: Sync,

§

impl<State> Unpin for CreationConfig<State>
where State: Unpin,

§

impl<State> UnsafeUnpin for CreationConfig<State>

§

impl<State> UnwindSafe for CreationConfig<State>
where State: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.