//! Write support: append-only extension and full-rebuild repack of `SqPack` archives.
//!
//! Two public entry points exist:
//!
//! - [`SqPackAppender`] — stages files in memory and commits them to an existing on-disk
//!   archive by appending to the `.dat` file and atomically replacing the index files.
//! - [`SqPackRepacker`] — builds a brand-new archive entirely in memory and writes the
//!   result with [`SqPackRepacker::write_to`] or [`SqPackRepacker::write_to_install`].
//!
//! Both paths DEFLATE-compress each file payload and align blocks to 128-byte boundaries.
//! Index files are rewritten with fresh SHA-1 checksums on every commit; see
//! [`FLATE2_DETERMINISM_NOTE`] for the caveats around byte-level reproducibility.

mod appender;
pub(crate) mod atomic;
pub(crate) mod index2_writer;
pub(crate) mod index_writer;
pub(crate) mod payload;
mod repack;
pub(crate) mod sha1;

pub use appender::{AppendOutcome, SqPackAppender};
pub use repack::{FLATE2_DETERMINISM_NOTE, REPACK_MAX_FILES, RepackedArchive, SqPackRepacker};

/// Maximum raw file size accepted by [`SqPackAppender::append`] and
/// [`SqPackRepacker::add_file`]: 1 GiB.
pub const APPEND_MAX_FILE_SIZE: u64 = 1 << 30;

/// Uncompressed chunk size used when splitting a payload into DEFLATE blocks: 16 KiB.
pub const APPEND_BLOCK_SIZE: u32 = 16384;

/// Hard upper bound on `.dat` file size enforced by both the appender and repacker: 2 GB.
pub const DAT_MAX_SIZE: u64 = 2_000_000_000;
