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>
impl CreationConfig<Unvalidated>
Sourcepub fn with_follow_symlinks(self, follow: bool) -> Self
pub fn with_follow_symlinks(self, follow: bool) -> Self
Sets whether to follow symlinks.
§Examples
use exarch_core::creation::CreationConfig;
let config = CreationConfig::default().with_follow_symlinks(true);
assert!(config.follow_symlinks);Sets whether to include hidden files.
§Examples
use exarch_core::creation::CreationConfig;
let config = CreationConfig::default().with_include_hidden(true);
assert!(config.include_hidden);Sourcepub fn with_max_file_size(self, max_size: Option<u64>) -> Self
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));Sourcepub fn with_exclude_patterns(self, patterns: Vec<String>) -> Self
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()]);Sourcepub fn with_strip_prefix(self, prefix: Option<PathBuf>) -> Self
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")));Sourcepub fn with_compression_level(self, level: u8) -> Result<Self>
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));Sourcepub fn with_preserve_permissions(self, preserve: bool) -> Self
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);Sourcepub fn with_format(self, format: Option<ArchiveType>) -> Self
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));Sourcepub fn validate(self) -> Result<CreationConfig<Validated>>
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>
impl<State: Clone> Clone for CreationConfig<State>
Source§fn clone(&self) -> CreationConfig<State>
fn clone(&self) -> CreationConfig<State>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<State: Debug> Debug for CreationConfig<State>
impl<State: Debug> Debug for CreationConfig<State>
Source§impl Default for CreationConfig<Unvalidated>
impl Default for CreationConfig<Unvalidated>
Source§impl<State> Deref for CreationConfig<State>
impl<State> Deref for CreationConfig<State>
Source§type Target = CreationConfigFields
type Target = CreationConfigFields
Source§fn deref(&self) -> &CreationConfigFields
fn deref(&self) -> &CreationConfigFields
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.
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.