1use std::fmt;
4
5pub type Result<T> = std::result::Result<T, Error>;
7
8#[derive(Debug, thiserror::Error)]
14#[non_exhaustive]
15pub enum Error {
16 #[error("io: {0}")]
17 Io(#[from] std::io::Error),
18 #[error("not a zip archive")]
20 NotZip,
21 #[error("compound file: a legacy .ppt or an encrypted package, not an ECMA-376 package")]
23 CompoundFile,
24 #[error("compound file holds no PowerPoint Document stream")]
26 NoPresentationStream,
27 #[error("encrypted: {0}")]
29 Encrypted(String),
30 #[error("zip: {msg} at offset {offset}")]
32 Zip { offset: u64, msg: String },
33 #[error("unsupported: {0}")]
35 Unsupported(String),
36 #[error("inflate: {0}")]
38 Inflate(String),
39 #[error("xml in {part} at byte {offset}: {msg}")]
41 Xml {
42 part: String,
43 offset: usize,
44 msg: String,
45 },
46 #[error("missing part: {0}")]
48 MissingPart(String),
49 #[error("missing relationship {id} in {part}")]
51 MissingRelationship { part: String, id: String },
52 #[error("not a presentation package")]
54 NotAPresentation,
55 #[error("slide {0} not found")]
56 SlideNotFound(usize),
57 #[error("{0}")]
58 Other(String),
59}
60
61impl Error {
62 pub(crate) fn zip(offset: u64, msg: impl fmt::Display) -> Self {
63 Error::Zip {
64 offset,
65 msg: msg.to_string(),
66 }
67 }
68}