Skip to content

Commit 3db1195

Browse files
authored
Share manifest struct with integration tests (#88)
1 parent 1a5bcfe commit 3db1195

File tree

19 files changed

+96
-103
lines changed

19 files changed

+96
-103
lines changed

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Casey Rodarmor <[email protected]>"]
55
autotests = false
66
categories = ["authentication", "command-line-utilities", "cryptography"]
77
description = "file verification utility"
8-
edition = "2021"
8+
edition = "2024"
99
homepage = "https://github.com/casey/filepack"
1010
keywords = ["checksum", "verification"]
1111
license = "CC0-1.0"
@@ -42,6 +42,8 @@ all = { level = "deny", priority = -1 }
4242
arbitrary-source-item-ordering = "deny"
4343
float-cmp = "allow"
4444
large_enum_variant = "allow"
45+
missing-errors-doc = "allow"
46+
missing-panics-doc = "allow"
4547
needless-pass-by-value = "allow"
4648
pedantic = { level = "deny", priority = -1 }
4749
result-large-err = "allow"

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
edition = "2021"
1+
edition = "2024"
22
max_width = 100
33
newline_style = "Unix"
44
tab_spaces = 2

src/arguments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use {
22
super::*,
33
clap::builder::{
4-
styling::{AnsiColor, Effects},
54
Styles,
5+
styling::{AnsiColor, Effects},
66
},
77
};
88

src/display_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::*;
22

33
#[derive(Debug)]
4-
pub(crate) struct DisplayPath(PathBuf);
4+
pub struct DisplayPath(PathBuf);
55

66
impl Display for DisplayPath {
77
fn fmt(&self, f: &mut Formatter) -> fmt::Result {

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
#[derive(Debug, Snafu)]
44
#[snafu(context(suffix(false)), visibility(pub(crate)))]
5-
pub(crate) enum Error {
5+
pub enum Error {
66
#[snafu(display("failed to get current directory"))]
77
CurrentDir { source: io::Error },
88
#[snafu(display("failed to get local data directory"))]

src/lib.rs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
use {
22
self::{
3-
arguments::Arguments, display_path::DisplayPath, display_secret::DisplaySecret, error::Error,
4-
lint::Lint, lint_group::LintGroup, list::List, manifest::Manifest, metadata::Metadata,
5-
options::Options, owo_colorize_ext::OwoColorizeExt, private_key::PrivateKey,
6-
public_key::PublicKey, relative_path::RelativePath, signature::Signature,
7-
signature_error::SignatureError, style::Style, subcommand::Subcommand, template::Template,
8-
utf8_path_ext::Utf8PathExt,
3+
arguments::Arguments, display_path::DisplayPath, display_secret::DisplaySecret, lint::Lint,
4+
lint_group::LintGroup, list::List, metadata::Metadata, options::Options,
5+
owo_colorize_ext::OwoColorizeExt, private_key::PrivateKey, signature_error::SignatureError,
6+
style::Style, subcommand::Subcommand, template::Template, utf8_path_ext::Utf8PathExt,
97
},
108
blake3::Hasher,
119
camino::{Utf8Component, Utf8Path, Utf8PathBuf},
@@ -15,7 +13,7 @@ use {
1513
owo_colors::Styled,
1614
serde::{Deserialize, Deserializer, Serialize, Serializer},
1715
serde_with::{DeserializeFromStr, SerializeDisplay},
18-
snafu::{ensure, ErrorCompat, OptionExt, ResultExt, Snafu},
16+
snafu::{ErrorCompat, OptionExt, ResultExt, Snafu, ensure},
1917
std::{
2018
array::TryFromSliceError,
2119
backtrace::{Backtrace, BacktraceStatus},
@@ -32,7 +30,10 @@ use {
3230
walkdir::WalkDir,
3331
};
3432

35-
pub use self::{entry::Entry, hash::Hash};
33+
pub use self::{
34+
entry::Entry, error::Error, hash::Hash, manifest::Manifest, public_key::PublicKey,
35+
relative_path::RelativePath, signature::Signature,
36+
};
3637

3738
#[cfg(test)]
3839
use assert_fs::TempDir;
@@ -91,12 +92,12 @@ pub fn run() {
9192
eprintln!(" {}─ {err}", if i < causes - 1 { '├' } else { '└' });
9293
}
9394

94-
if let Some(backtrace) = err.backtrace() {
95-
if backtrace.status() == BacktraceStatus::Captured {
96-
eprintln!();
97-
eprintln!("backtrace:");
98-
eprintln!("{backtrace}");
99-
}
95+
if let Some(backtrace) = err.backtrace()
96+
&& backtrace.status() == BacktraceStatus::Captured
97+
{
98+
eprintln!();
99+
eprintln!("backtrace:");
100+
eprintln!("{backtrace}");
100101
}
101102

102103
process::exit(1);

src/manifest.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use super::*;
22

33
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
44
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
5-
pub(crate) struct Manifest {
5+
pub struct Manifest {
66
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
7-
pub(crate) files: BTreeMap<RelativePath, Entry>,
7+
pub files: BTreeMap<RelativePath, Entry>,
88
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
9-
pub(crate) signatures: BTreeMap<PublicKey, Signature>,
9+
pub signatures: BTreeMap<PublicKey, Signature>,
1010
}
1111

1212
impl Manifest {
@@ -25,7 +25,7 @@ impl Manifest {
2525
hasher.finalize().into()
2626
}
2727

28-
pub(crate) fn load(path: Option<&Utf8Path>) -> Result<(Utf8PathBuf, Self)> {
28+
pub fn load(path: Option<&Utf8Path>) -> Result<(Utf8PathBuf, Self)> {
2929
let path = if let Some(path) = path {
3030
if filesystem::metadata(path)?.is_dir() {
3131
path.join(Manifest::FILENAME)
@@ -45,7 +45,7 @@ impl Manifest {
4545
Ok((path, manifest))
4646
}
4747

48-
pub(crate) fn save(&self, path: &Utf8Path) -> Result<()> {
48+
pub fn save(&self, path: &Utf8Path) -> Result<()> {
4949
filesystem::write(path, format!("{}\n", serde_json::to_string(self).unwrap()))
5050
}
5151
}

src/private_key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
#[derive(Debug, Snafu)]
44
#[snafu(context(suffix(Error)))]
5-
pub(crate) enum Error {
5+
pub enum Error {
66
#[snafu(display("invalid private key hex"))]
77
Hex { source: hex::FromHexError },
88
#[snafu(display("invalid private key byte length {length}"))]

src/public_key.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::*;
22

33
#[derive(Debug, Snafu)]
44
#[snafu(context(suffix(Error)))]
5-
pub(crate) enum Error {
5+
pub enum Error {
66
#[snafu(display("invalid public key hex: `{key}`"))]
77
Hex {
88
key: String,
@@ -21,7 +21,7 @@ pub(crate) enum Error {
2121
}
2222

2323
#[derive(Clone, Debug, DeserializeFromStr, Eq, PartialEq, SerializeDisplay)]
24-
pub(crate) struct PublicKey(ed25519_dalek::VerifyingKey);
24+
pub struct PublicKey(ed25519_dalek::VerifyingKey);
2525

2626
impl PublicKey {
2727
const LEN: usize = ed25519_dalek::PUBLIC_KEY_LENGTH;
@@ -38,7 +38,7 @@ impl PublicKey {
3838
Ok(public_key)
3939
}
4040

41-
pub(crate) fn verify(&self, message: &[u8], signature: &Signature) -> Result<()> {
41+
pub fn verify(&self, message: &[u8], signature: &Signature) -> Result<()> {
4242
self
4343
.0
4444
.verify_strict(message, signature.as_ref())

src/relative_path.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub(crate) use self::error::Error;
55
mod error;
66

77
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)]
8-
pub(crate) struct RelativePath(String);
8+
pub struct RelativePath(String);
99

1010
impl RelativePath {
1111
const JUNK_NAMES: [&'static str; 2] = [".DS_Store", ".localized"];
@@ -140,10 +140,10 @@ impl FromStr for RelativePath {
140140
let mut chars = s.chars();
141141
let first = chars.next();
142142
let second = chars.next();
143-
if let Some((first, second)) = first.zip(second) {
144-
if second == ':' {
145-
return Err(Error::WindowsDiskPrefix { letter: first });
146-
}
143+
if let Some((first, second)) = first.zip(second)
144+
&& second == ':'
145+
{
146+
return Err(Error::WindowsDiskPrefix { letter: first });
147147
}
148148

149149
let mut path = String::new();

0 commit comments

Comments
 (0)