apple_xar/
lib.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

/*! XAR file format */

pub mod format;
pub mod reader;
#[cfg(feature = "signing")]
pub mod signing;
pub mod table_of_contents;

#[derive(Debug, thiserror::Error)]
pub enum Error {
    #[error("(de)serialization error: {0}")]
    Scroll(#[from] scroll::Error),

    #[error("unable to parse checksum string: {0}")]
    BadChecksum(&'static str),

    #[error("I/O error: {0}")]
    Io(#[from] std::io::Error),

    #[error("decompression error: {0}")]
    Decompress(#[from] flate2::DecompressError),

    #[error("XML error: {0}")]
    SerdeXml(#[from] serde_xml_rs::Error),

    #[error("XML write error: {0}")]
    XmlWrite(#[from] xml::writer::Error),

    #[error("Invalid file ID")]
    InvalidFileId,

    #[error("table of contents is corrupted: {0}")]
    TableOfContentsCorrupted(&'static str),

    #[error("File has no data")]
    FileNoData,

    #[error("Unimplemented file encoding: {0}")]
    UnimplementedFileEncoding(String),

    #[error("Operation not supported: {0}")]
    Unsupported(&'static str),

    #[error("x509 certificate error: {0}")]
    X509Certificate(#[from] x509_certificate::X509CertificateError),

    #[cfg(feature = "signing")]
    #[error("signing error: {0}")]
    SignatureCreation(#[from] signature::Error),

    #[cfg(feature = "signing")]
    #[error("CMS error: {0}")]
    Cms(#[from] cryptographic_message_syntax::CmsError),

    #[cfg(feature = "signing")]
    #[error("HTTP error: {0}")]
    Reqwest(#[from] reqwest::Error),
}

pub type XarResult<T> = std::result::Result<T, Error>;