#![cfg_attr(
all(doc, feature = "document-features"),
doc = ::document_features::document_features!()
)]
#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg))]
#![deny(rust_2018_idioms, missing_docs)]
#![forbid(unsafe_code)]
use bstr::BString;
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
NextStreamEntry(#[from] gix_worktree_stream::entry::Error),
#[error("The internal format cannot be used as an archive, it's merely a debugging tool")]
InternalFormatMustNotPersist,
#[error("Support for the format '{wanted:?}' was not compiled in")]
SupportNotCompiledIn { wanted: Format },
#[error("Cannot create a zip archive if output stream does not support seek")]
ZipWithoutSeek,
#[error("Cannot use modification as it is not within the supported bounds")]
InvalidModificationTime(#[source] Box<dyn std::error::Error + Send + Sync + 'static>),
}
#[derive(Default, PartialEq, Eq, Copy, Clone, Debug)]
pub enum Format {
#[default]
InternalTransientNonPersistable,
Tar,
TarGz {
compression_level: Option<u8>,
},
Zip {
compression_level: Option<u8>,
},
}
#[derive(Clone, Debug)]
pub struct Options {
pub format: Format,
pub tree_prefix: Option<BString>,
pub modification_time: gix_date::SecondsSinceUnixEpoch,
}
impl Default for Options {
fn default() -> Self {
Options {
format: Default::default(),
tree_prefix: None,
modification_time: std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.map(|t| t.as_secs() as i64)
.unwrap_or_default(),
}
}
}
mod write;
pub use write::{write_stream, write_stream_seek};