1mod bin;
2pub mod ext;
3mod package;
4mod transaction;
5
6pub use bin::*;
7pub use package::*;
8pub use transaction::*;
9
10use std::io;
11use std::path::PathBuf;
12
13use pkgar_core::Entry;
14
15const READ_WRITE_HASH_BUF_SIZE: usize = 4 * 1024 * 1024;
16
17#[derive(Debug, thiserror::Error)]
18pub enum Error {
19 #[error(transparent)]
20 Core(#[from] pkgar_core::Error),
21 #[error(transparent)]
22 Keys(#[from] pkgar_keys::Error),
23 #[error("{source} ({path:?})")]
24 Io {
25 #[source]
26 source: io::Error,
27 path: Option<PathBuf>,
28 },
29 #[error("Failed to commit transaction. {changed} files changed; {remaining} files remaining")]
30 FailedCommit {
31 #[source]
32 source: Box<Self>,
33 changed: usize,
34 remaining: usize,
35 },
36 #[error("Invalid component '{}' in path '{}'{}", invalid.display(), path.display(), entry.as_ref().map(|_| " while parsing entry").unwrap_or_default())]
37 InvalidPathComponent {
38 invalid: PathBuf,
39 path: PathBuf,
40 entry: Option<Box<Entry>>,
41 },
42 #[error("Entry size mismatch: expected {expected}; got {actual}")]
43 LengthMismatch { actual: u64, expected: u64 },
44}