Skip to content

Commit

Permalink
Add common error type
Browse files Browse the repository at this point in the history
  • Loading branch information
Kijewski committed Sep 14, 2023
1 parent f8c044a commit 61ae9c6
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zipsign"
description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key"
version = "0.1.0-a.0"
version = "0.1.0-a.1"
edition = "2021"
authors = ["René Kijewski <[email protected]>"]
repository = "https://github.com/Kijewski/zipsign"
Expand All @@ -22,7 +22,7 @@ thiserror = "1"
zip = { version = "0.6", default-features = false }

[workspace.dependencies.zipsign-api]
version = "0.1.0-a.0"
version = "0.1.0-a.1"
path = "api"
default-features = false
features = ["verify-tar", "verify-zip", "sign-tar", "sign-zip"]
Expand Down
8 changes: 4 additions & 4 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "zipsign-api"
description = "Sign and verify `.zip` and `.tar.gz` files with an ed25519 signing key"
version = "0.1.0-a.0"
version = "0.1.0-a.1"
edition = "2021"
authors = ["René Kijewski <[email protected]>"]
repository = "https://github.com/Kijewski/zipsign"
Expand All @@ -10,17 +10,17 @@ license = "Apache-2.0 WITH LLVM-exception"
[dependencies]
base64 = { workspace = true, optional = true }
ed25519-dalek.workspace = true
thiserror = { workspace = true, optional = true }
thiserror.workspace = true
zip = { workspace = true, optional = true }

[features]
default = ["tar", "zip"]

verify = ["dep:thiserror"]
verify = []
verify-tar = ["verify", "dep:base64"]
verify-zip = ["verify"]

sign = ["dep:thiserror"]
sign = []
sign-tar = ["sign", "dep:base64"]
sign-zip = ["sign", "dep:zip"]

Expand Down
47 changes: 47 additions & 0 deletions api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,50 @@ where
let _: u64 = copy(input, &mut prehashed_message)?;
Ok(prehashed_message)
}

/// A collection of all error this library can return
#[non_exhaustive]
#[derive(Debug, thiserror::Error)]
#[error(transparent)]
pub enum ZipsignError {
/// An error returned by [`gather_signature_data()`][self::sign::gather_signature_data]
#[cfg(feature = "sign")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign")))]
GatherSignatureData(#[from] self::sign::GatherSignatureDataError),
/// An error returned by [`read_signing_keys()`][self::sign::read_signing_keys]
#[cfg(feature = "sign")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign")))]
ReadSigningKeys(#[from] self::sign::ReadSigningKeysError),
/// An error returned by [`copy_and_sign_tar()`][self::sign::copy_and_sign_tar]
#[cfg(feature = "sign-tar")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign-tar")))]
SignTar(#[from] self::sign::SignTarError),
/// An error returned by [`copy_and_sign_zip()`][self::sign::copy_and_sign_zip]
#[cfg(feature = "sign-zip")]
#[cfg_attr(docsrs, doc(cfg(feature = "sign-zip")))]
SignZip(#[from] self::sign::SignZipError),

/// No matching key/signature pair found
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
NoMatch(#[from] self::verify::NoMatch),
/// An error returned by [`collect_keys()`][self::verify::collect_keys]
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
CollectKeys(#[from] self::verify::CollectKeysError),
/// An error returned by [`read_signatures()`][self::verify::read_signatures]
#[cfg(feature = "verify")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify")))]
ReadSignatures(#[from] self::verify::ReadSignaturesError),
/// An error returned by [`verify_tar()`][self::verify::verify_tar]
#[cfg(feature = "verify-tar")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify-tar")))]
VerifyTar(#[from] self::verify::VerifyTarError),
/// An error retuned by [`verify_zip()`][self::verify::verify_zip]
#[cfg(feature = "verify-zip")]
#[cfg_attr(docsrs, doc(cfg(feature = "verify-zip")))]
VerifyZip(#[from] self::verify::VerifyZipError),

/// An I/O occurred
Io(#[from] std::io::Error),
}

0 comments on commit 61ae9c6

Please sign in to comment.