Skip to content

Commit bbdd583

Browse files
committed
Remove io::Error -> getrandom::Error conversion
Also remove Error::UNKNOWN_IO_ERROR constant
1 parent b6839f6 commit bbdd583

File tree

2 files changed

+0
-14
lines changed

2 files changed

+0
-14
lines changed

src/error.rs

-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ impl Error {
3131
pub const UNSUPPORTED: Error = internal_error!(0);
3232
/// The platform-specific `errno` returned a non-positive value.
3333
pub const ERRNO_NOT_POSITIVE: Error = internal_error!(1);
34-
/// Invalid conversion from a non-standard [`std::io::Error`](https://doc.rust-lang.org/std/io/struct.Error.html)
35-
pub const UNKNOWN_IO_ERROR: Error = internal_error!(2);
3634
/// Call to [`SecRandomCopyBytes`](https://developer.apple.com/documentation/security/1399291-secrandomcopybytes) failed.
3735
pub const SEC_RANDOM_FAILED: Error = internal_error!(3);
3836
/// Call to [`RtlGenRandom`](https://docs.microsoft.com/en-us/windows/win32/api/ntsecapi/nf-ntsecapi-rtlgenrandom) failed.
@@ -157,7 +155,6 @@ fn internal_desc(error: Error) -> Option<&'static str> {
157155
match error {
158156
Error::UNSUPPORTED => Some("getrandom: this target is not supported"),
159157
Error::ERRNO_NOT_POSITIVE => Some("errno: did not return a positive value"),
160-
Error::UNKNOWN_IO_ERROR => Some("Unknown std::io::Error"),
161158
Error::SEC_RANDOM_FAILED => Some("SecRandomCopyBytes: call failed"),
162159
Error::RTL_GEN_RANDOM_FAILED => Some("RtlGenRandom: call failed"),
163160
Error::FAILED_RDRAND => Some("RDRAND: failed multiple times: CPU issue likely"),

src/error_impls.rs

-11
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ use core::convert::From;
1212
use core::num::NonZeroU32;
1313
use std::io;
1414

15-
impl From<io::Error> for Error {
16-
fn from(err: io::Error) -> Self {
17-
if let Some(errno) = err.raw_os_error() {
18-
if let Some(code) = NonZeroU32::new(errno as u32) {
19-
return Error::from(code);
20-
}
21-
}
22-
Error::UNKNOWN_IO_ERROR
23-
}
24-
}
25-
2615
impl From<Error> for io::Error {
2716
fn from(err: Error) -> Self {
2817
match err.raw_os_error() {

0 commit comments

Comments
 (0)