Skip to content

Commit 66c8622

Browse files
feat: Misc. API and docs cleanups
Signed-off-by: Andrew Lilley Brinker <[email protected]>
1 parent e3752c1 commit 66c8622

File tree

10 files changed

+244
-209
lines changed

10 files changed

+244
-209
lines changed

omnibor/benches/benchmark.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ fn bench_rustcrypto_sha256_small(c: &mut Criterion) {
2525

2626
let name = "OmniBOR RustCrypto SHA-256 11B";
2727
let input = b"hello world";
28-
set_hash_provider::<Sha256, RustCrypto>().unwrap();
28+
set_hash_provider::<Sha256, RustCrypto>();
2929

3030
c.bench_function(name, |b| {
3131
b.iter(|| {
32-
let _ = ArtifactId::<Sha256>::new(black_box(input)).unwrap();
32+
let _ = ArtifactId::sha256(black_box(input)).unwrap();
3333
})
3434
});
3535
}
@@ -40,11 +40,11 @@ fn bench_boring_sha256_small(c: &mut Criterion) {
4040

4141
let name = "OmniBOR BoringSSL SHA-256 11B";
4242
let input = b"hello world";
43-
set_hash_provider::<Sha256, BoringSsl>().unwrap();
43+
set_hash_provider::<Sha256, BoringSsl>();
4444

4545
c.bench_function(name, |b| {
4646
b.iter(|| {
47-
let _ = ArtifactId::<Sha256>::new(black_box(input));
47+
let _ = ArtifactId::sha256(black_box(input));
4848
})
4949
});
5050
}
@@ -55,11 +55,11 @@ fn bench_openssl_sha256_small(c: &mut Criterion) {
5555

5656
let name = "OmniBOR OpenSSL SHA-256 11B";
5757
let input = b"hello world";
58-
set_hash_provider::<Sha256, OpenSsl>().unwrap();
58+
set_hash_provider::<Sha256, OpenSsl>();
5959

6060
c.bench_function(name, |b| {
6161
b.iter(|| {
62-
let _ = ArtifactId::<Sha256>::new(black_box(input));
62+
let _ = ArtifactId::sha256(black_box(input));
6363
})
6464
});
6565
}
@@ -70,11 +70,11 @@ fn bench_rustcrypto_sha256_large(c: &mut Criterion) {
7070

7171
let name = "OmniBOR RustCrypto SHA-256 100MB";
7272
let input = &[0; 1024 * 1024 * 100]; // 100 MB
73-
set_hash_provider::<Sha256, RustCrypto>().unwrap();
73+
set_hash_provider::<Sha256, RustCrypto>();
7474

7575
c.bench_function(name, |b| {
7676
b.iter(|| {
77-
let _ = ArtifactId::<Sha256>::new(black_box(input)).unwrap();
77+
let _ = ArtifactId::sha256(black_box(input)).unwrap();
7878
})
7979
});
8080
}
@@ -85,11 +85,11 @@ fn bench_boring_sha256_large(c: &mut Criterion) {
8585

8686
let name = "OmniBOR BoringSSL SHA-256 100MB";
8787
let input = &[0; 1024 * 1024 * 100]; // 100 MB
88-
set_hash_provider::<Sha256, BoringSsl>().unwrap();
88+
set_hash_provider::<Sha256, BoringSsl>();
8989

9090
c.bench_function(name, |b| {
9191
b.iter(|| {
92-
let _ = ArtifactId::<Sha256>::new(black_box(input)).unwrap();
92+
let _ = ArtifactId::sha256(black_box(input)).unwrap();
9393
})
9494
});
9595
}
@@ -100,11 +100,11 @@ fn bench_openssl_sha256_large(c: &mut Criterion) {
100100

101101
let name = "OmniBOR OpenSSL SHA-256 100MB";
102102
let input = &[0; 1024 * 1024 * 100]; // 100 MB
103-
set_hash_provider::<Sha256, OpenSsl>().unwrap();
103+
set_hash_provider::<Sha256, OpenSsl>();
104104

105105
c.bench_function(name, |b| {
106106
b.iter(|| {
107-
let _ = ArtifactId::<Sha256>::new(black_box(input)).unwrap();
107+
let _ = ArtifactId::sha256(black_box(input)).unwrap();
108108
})
109109
});
110110
}

omnibor/src/artifact_id/identify_async.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
22
error::ArtifactIdError, gitoid::internal::gitoid_from_async_reader,
3-
hash_algorithm::HashAlgorithm, hash_provider::registry::get_hash_provider_async,
4-
object_type::Blob, util::clone_as_boxstr::CloneAsBoxstr, ArtifactId,
3+
hash_algorithm::HashAlgorithm, hash_provider::registry::get_hash_provider, object_type::Blob,
4+
util::clone_as_boxstr::CloneAsBoxstr, ArtifactId,
55
};
66
use std::{
77
ffi::{OsStr, OsString},
@@ -92,7 +92,7 @@ where
9292
H: HashAlgorithm,
9393
{
9494
async fn identify_async(self) -> Result<ArtifactId<H>, ArtifactIdError> {
95-
let mut digester = get_hash_provider_async().await.digester();
95+
let mut digester = get_hash_provider().digester();
9696
let gitoid = gitoid_from_async_reader::<H, Blob, _>(&mut *digester, self).await?;
9797
Ok(ArtifactId::from_gitoid(gitoid))
9898
}
@@ -113,7 +113,7 @@ where
113113
R: AsyncRead + AsyncSeek + Unpin,
114114
{
115115
async fn identify_async(self) -> Result<ArtifactId<H>, ArtifactIdError> {
116-
let mut digester = get_hash_provider_async().await.digester();
116+
let mut digester = get_hash_provider().digester();
117117
let gitoid = gitoid_from_async_reader::<H, Blob, _>(&mut *digester, self).await?;
118118
Ok(ArtifactId::from_gitoid(gitoid))
119119
}

omnibor/src/error.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
//! Error types for working with `ArtifactId`s and `InputManifest`s.
22
33
pub(crate) mod artifact_id_error;
4-
pub(crate) mod hash_provider_error;
54
pub(crate) mod input_manifest_error;
65

76
pub use crate::error::artifact_id_error::ArtifactIdError;
8-
pub use crate::error::hash_provider_error::HashProviderError;
97
pub use crate::error::input_manifest_error::InputManifestError;

omnibor/src/error/hash_provider_error.rs

Lines changed: 0 additions & 26 deletions
This file was deleted.

omnibor/src/error/input_manifest_error.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use {
55
std::io::Error as IoError,
66
};
77

8-
use crate::error::HashProviderError;
98
#[cfg(doc)]
109
use crate::{artifact_id::ArtifactId, input_manifest::InputManifest};
1110

@@ -155,9 +154,6 @@ pub enum InputManifestError {
155154

156155
/// Failed to initialize hash providers.
157156
FailedToInitHashProviders,
158-
159-
/// Hash provider errors.
160-
HashProviderError(HashProviderError),
161157
}
162158

163159
impl InputManifestError {
@@ -235,7 +231,6 @@ impl Display for InputManifestError {
235231
},
236232
InputManifestError::InvalidCharInManifest => write!(f, "invalid character in manifest"),
237233
InputManifestError::FailedToInitHashProviders => write!(f, "failed to initialize hash providers"),
238-
InputManifestError::HashProviderError(source) => write!(f, "{source}"),
239234
}
240235
}
241236
}
@@ -284,7 +279,6 @@ impl Error for InputManifestError {
284279
InputManifestError::FailedStorageCleanup(_, source) => Some(source),
285280
InputManifestError::CantRemoveManifest(source) => Some(source),
286281
InputManifestError::CantEmbedInTarget(_, source) => Some(source),
287-
InputManifestError::HashProviderError(source) => Some(source),
288282
}
289283
}
290284
}
@@ -294,9 +288,3 @@ impl From<ArtifactIdError> for InputManifestError {
294288
InputManifestError::ArtifactIdError(value)
295289
}
296290
}
297-
298-
impl From<HashProviderError> for InputManifestError {
299-
fn from(value: HashProviderError) -> Self {
300-
InputManifestError::HashProviderError(value)
301-
}
302-
}

0 commit comments

Comments
 (0)