Skip to content

Commit 0397384

Browse files
authored
digest: move std::io stuff to digest-io (#1809)
The `digest-io` crate is added in RustCrypto/utils#1172
1 parent 67131af commit 0397384

File tree

10 files changed

+9
-315
lines changed

10 files changed

+9
-315
lines changed

.github/workflows/digest.yml

-1
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,4 @@ jobs:
6060
- run: cargo test
6161
- run: cargo test --features dev
6262
- run: cargo test --features alloc
63-
- run: cargo test --features std
6463
- run: cargo test --all-features

crypto/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ universal-hash = { version = "0.6.0-rc.0", path = "../universal-hash", optional
2626

2727
[features]
2828
std = [
29-
"digest/std",
3029
"elliptic-curve/std",
3130
"signature/std",
3231
]

digest/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
### Removed
1717
- `Mac::new`, `Mac::new_from_slice`, and `Mac::generate_key` methods ([#1173])
18+
- `HashReader` and `HashWriter` are moved to the `digest-io` crate ([#1809])
19+
- Removed `io::Write/Read` implementations in favor of the `digest_io::IoWrapper` type ([#1809])
1820

1921
[#1173]: https://github.com/RustCrypto/traits/pull/1173
2022
[#1334]: https://github.com/RustCrypto/traits/pull/1334
2123
[#1759]: https://github.com/RustCrypto/traits/pull/1759
24+
[#1809]: https://github.com/RustCrypto/traits/pull/1809
2225

2326
## 0.10.7 (2023-05-19)
2427
### Changed

digest/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ os_rng = ["crypto-common/rand_core", "rand_core"]
3131
oid = ["const-oid"]
3232
zeroize = ["dep:zeroize", "block-buffer?/zeroize"]
3333
alloc = []
34-
std = ["alloc"]
3534
dev = ["blobby"]
3635

3736
[package.metadata.docs.rs]

digest/src/core_api/rt_variable.rs

-14
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,3 @@ where
184184
})
185185
}
186186
}
187-
188-
#[cfg(feature = "std")]
189-
impl<T: VariableOutputCore> std::io::Write for RtVariableCoreWrapper<T> {
190-
#[inline]
191-
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
192-
Update::update(self, buf);
193-
Ok(buf.len())
194-
}
195-
196-
#[inline]
197-
fn flush(&mut self) -> std::io::Result<()> {
198-
Ok(())
199-
}
200-
}

digest/src/core_api/wrapper.rs

-14
Original file line numberDiff line numberDiff line change
@@ -220,20 +220,6 @@ where
220220
}
221221
}
222222

223-
#[cfg(feature = "std")]
224-
impl<T: BufferKindUser + UpdateCore> std::io::Write for CoreWrapper<T> {
225-
#[inline]
226-
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
227-
Update::update(self, buf);
228-
Ok(buf.len())
229-
}
230-
231-
#[inline]
232-
fn flush(&mut self) -> std::io::Result<()> {
233-
Ok(())
234-
}
235-
}
236-
237223
/// A proxy trait to a core type implemented by [`CoreWrapper`]
238224
// TODO: replace with an inherent associated type on stabilization:
239225
// https://github.com/rust-lang/rust/issues/8995

digest/src/core_api/xof_reader.rs

-12
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,6 @@ where
3636
}
3737
}
3838

39-
#[cfg(feature = "std")]
40-
impl<T> std::io::Read for XofReaderCoreWrapper<T>
41-
where
42-
T: XofReaderCore,
43-
{
44-
#[inline]
45-
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
46-
XofReader::read(self, buf);
47-
Ok(buf.len())
48-
}
49-
}
50-
5139
impl<T: XofReaderCore> Drop for XofReaderCoreWrapper<T> {
5240
#[inline]
5341
fn drop(&mut self) {

digest/src/hashreader.rs

-136
This file was deleted.

digest/src/hashwriter.rs

-121
This file was deleted.

digest/src/lib.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@
1818
//! Usually they should not be used in application-level code.
1919
//!
2020
//! Additionally hash functions implement traits from the standard library:
21-
//! [`Default`], [`Clone`], [`Write`][std::io::Write]. The latter is
22-
//! feature-gated behind `std` feature, which is usually enabled by default
23-
//! by hash implementation crates.
21+
//! [`Default`] and [`Clone`].
22+
//!
23+
//! This crate does not provide any implementations of the `io::Read/Write` traits,
24+
//! see the [`digest-io`] crate for `std::io`-compatibility wrappers.
25+
//!
26+
//! [`digest-io`]: https://docs.rs/digest-io
2427
2528
#![no_std]
2629
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
@@ -35,9 +38,6 @@
3538
#[macro_use]
3639
extern crate alloc;
3740

38-
#[cfg(feature = "std")]
39-
extern crate std;
40-
4141
#[cfg(feature = "rand_core")]
4242
pub use crypto_common::rand_core;
4343

@@ -303,12 +303,3 @@ impl fmt::Display for InvalidBufferSize {
303303
}
304304

305305
impl core::error::Error for InvalidBufferSize {}
306-
307-
#[cfg(feature = "std")]
308-
mod hashwriter;
309-
#[cfg(feature = "std")]
310-
pub use hashwriter::HashWriter;
311-
#[cfg(feature = "std")]
312-
mod hashreader;
313-
#[cfg(feature = "std")]
314-
pub use hashreader::HashReader;

0 commit comments

Comments
 (0)