voa_openpgp/import/destructured/
error.rs

1//! Error handling for importing destructured [OpenPGP certificates] as [VOA] verifiers.
2//!
3//! [OpenPGP certificates]: https://openpgp.dev/book/certificates.html
4//! [VOA]: https://uapi-group.org/specifications/specs/file_hierarchy_for_the_verification_of_os_artifacts/
5
6use std::path::PathBuf;
7
8use pgp::types::{Fingerprint, Tag};
9
10/// The error that can occur when importing verifiers.
11#[derive(Debug, thiserror::Error)]
12pub enum Error {
13    /// There is an additional, unwanted OpenPGP certificate.
14    #[error("There is an excess OpenPGP certificate with fingerprint {fingerprint} in {path:?}")]
15    ExcessCertificateInDir {
16        /// The directory path in which OpenPGP packets of more than one OpenPGP certificate are
17        /// present.
18        path: PathBuf,
19        /// The OpenPGP fingerprint of the excess OpenPGP certificate.
20        fingerprint: Fingerprint,
21    },
22
23    /// There is an additional, unwanted OpenPGP packet in a file.
24    #[error("There is an excess {tag:?} OpenPGP packet in file {path:?}")]
25    ExcessPacket {
26        /// The path of the file in which an excess OpenPGP packet is present.
27        path: PathBuf,
28        /// The excess OpenPGP packet.
29        tag: Tag,
30    },
31
32    /// A regular file is empty.
33    #[error("The file {path:?} is empty.")]
34    FileIsEmpty {
35        /// The path of the empty file.
36        path: PathBuf,
37    },
38
39    /// A directory does not have a valid Arch Linux keyring structure.
40    #[error("The import directory {path:?} does not contain a valid Arch Linux keyring structure")]
41    InvalidArchLinuxKeyringStructure {
42        /// The path to the directory that is not a valid Arch Linux keyring structure.
43        path: PathBuf,
44    },
45
46    /// A directory does not have a valid flat structure.
47    #[error("The import directory {path:?} does not contain a valid flat structure")]
48    InvalidFlatStructure {
49        /// The path to the directory that does not contain a flat structure.
50        path: PathBuf,
51    },
52
53    /// An OpenPGP certificate cannot be constructed from OpenPGP packets in a directory.
54    #[error("No OpenPGP certificate can be constructed from the directory {path:?}")]
55    NoOpenPgpCertInDir {
56        /// The directory path from which no OpenPGP certificate can be constructed.
57        path: PathBuf,
58    },
59
60    /// There is no OpenPGP packet in a file.
61    #[error("There is no OpenPGP packet in file {path:?}")]
62    NoPacketInFile {
63        /// The path at which no packet
64        path: PathBuf,
65    },
66
67    /// A path is not a directory.
68    #[error("The path {path:?} is not a directory.")]
69    PathIsNotADir {
70        /// The path that is not a directory.
71        path: PathBuf,
72    },
73}