agentmux_srv_core/backend/agent_archive/
mod.rs1pub mod build;
10pub mod definition;
11pub mod manifest;
12pub mod place;
13pub mod reader;
14pub mod transcript_md;
15pub mod writer;
16
17#[cfg(test)]
18mod build_tests;
19#[cfg(test)]
20mod place_tests;
21#[cfg(test)]
22mod tests;
23
24pub use manifest::{Manifest, Part, SignatureState};
25pub use reader::ArchiveReader;
26pub use writer::ArchiveWriter;
27
28#[derive(Debug, Clone, Copy)]
30pub struct Limits {
31 pub max_parts: usize,
32 pub max_part_bytes: u64,
33 pub max_total_bytes: u64,
34}
35
36impl Default for Limits {
37 fn default() -> Self {
38 Self { max_parts: 20_000, max_part_bytes: 4 << 30, max_total_bytes: 8 << 30 }
39 }
40}
41
42#[derive(Debug, thiserror::Error, PartialEq, Eq)]
43pub enum ArchiveError {
44 #[error("this is not an agent archive: {0}")]
45 NotAnArchive(String),
46 #[error("the archive has no manifest")]
47 NoManifest,
48 #[error("the archive's manifest is malformed: {0}")]
49 Malformed(String),
50 #[error("this is a {0:?} archive, not an agent archive")]
51 WrongKind(String),
52 #[error("this archive is format {archive}; this AgentMux reads up to format {supported}. Upgrade it, then import.")]
53 TooNew { archive: u32, supported: u32 },
54 #[error("the name {0:?} is not a plain relative name")]
55 BadPath(String),
56 #[error("the part {0:?} is in the archive twice")]
57 DuplicatePart(String),
58 #[error("the archive has more than {0} parts")]
59 TooManyParts(usize),
60 #[error("the part {0:?} is larger than the {1} bytes an archive may hold in one part")]
61 PartTooBig(String, u64),
62 #[error("the archive holds more than the {0} bytes an archive may")]
63 TooBig(u64),
64 #[error("{0:?} is a link or a directory, not a file")]
65 NotPlainFile(String),
66 #[error("the archive holds {0:?}, which its manifest does not list")]
67 UnlistedEntry(String),
68 #[error("the archive is missing {0:?}, which its manifest lists")]
69 MissingEntry(String),
70 #[error("the part {0:?} has been changed: {1}")]
71 PartChanged(String, String),
72 #[error("the archive has no part {0:?}")]
73 NoSuchPart(String),
74 #[error("{0}")]
75 Io(String),
76}