Skip to content

Commit 13d49ec

Browse files
committed
Remove error module from API
1 parent 7d93104 commit 13d49ec

19 files changed

+29
-29
lines changed

src/cloudabi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
extern crate cloudabi;
1212

1313
use core::num::NonZeroU32;
14-
use error::Error;
14+
use Error;
1515

1616
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
1717
let errno = unsafe { cloudabi::random_get(dest) };

src/dragonfly_haiku.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// except according to those terms.
88

99
//! Implementation for DragonFly / Haiku
10-
use error::Error;
10+
use Error;
1111
use utils::use_init;
1212
use std::fs::File;
1313
use std::io::Read;

src/dummy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// except according to those terms.
88

99
//! A dummy implementation for unsupported targets which always returns
10-
//! `Err(error::UNAVAILABLE)`
10+
//! `Err(ERROR_UNAVAILABLE)`
1111
use std::num::NonZeroU32;
12-
use error::{Error, UNAVAILABLE};
12+
use {Error, ERROR_UNAVAILABLE};
1313

1414
pub fn getrandom_inner(_: &mut [u8]) -> Result<(), Error> {
15-
Err(UNAVAILABLE)
15+
Err(ERROR_UNAVAILABLE)
1616
}
1717

1818
#[inline(always)]

src/emscripten.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// except according to those terms.
88

99
//! Implementation for Emscripten
10-
use error::Error;
10+
use Error;
1111
use std::fs::File;
1212
use std::io::Read;
1313
use std::cell::RefCell;

src/error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ const CODE_UNKNOWN: u32 = CODE_PREFIX | 0;
1818
const CODE_UNAVAILABLE: u32 = CODE_PREFIX | 1;
1919

2020
/// An unknown error.
21-
pub const UNKNOWN: Error = Error(unsafe {
2221
///
2322
/// This is the following constant: 57F40000 (hex) / 1475608576 (decimal).
23+
pub const ERROR_UNKNOWN: Error = Error(unsafe {
2424
NonZeroU32::new_unchecked(CODE_UNKNOWN)
2525
});
2626

2727
/// No generator is available.
28-
pub const UNAVAILABLE: Error = Error(unsafe {
2928
///
3029
/// This is the following constant: 57F40001 (hex) / 1475608577 (decimal).
30+
pub const ERROR_UNAVAILABLE: Error = Error(unsafe {
3131
NonZeroU32::new_unchecked(CODE_UNAVAILABLE)
3232
});
3333

@@ -53,8 +53,8 @@ impl Error {
5353
Some(msg)
5454
} else {
5555
match *self {
56-
UNKNOWN => Some("getrandom: unknown error"),
57-
UNAVAILABLE => Some("getrandom: unavailable"),
56+
ERROR_UNKNOWN => Some("getrandom: unknown error"),
57+
ERROR_UNAVAILABLE => Some("getrandom: unavailable"),
5858
_ => None
5959
}
6060
}
@@ -92,7 +92,7 @@ impl From<io::Error> for Error {
9292
.and_then(|code| NonZeroU32::new(code as u32))
9393
.map(|code| Error(code))
9494
// in practice this should never happen
95-
.unwrap_or(UNKNOWN)
95+
.unwrap_or(ERROR_UNKNOWN)
9696
}
9797
}
9898

src/freebsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Implementation for FreeBSD
1010
extern crate libc;
1111

12-
use error::Error;
12+
use Error;
1313
use core::ptr;
1414
use std::io;
1515
use std::num::NonZeroU32;

src/fuchsia.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
extern crate fuchsia_cprng;
1111

1212
use std::num::NonZeroU32;
13-
use error::Error;
13+
use Error;
1414

1515
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
1616
fuchsia_cprng::cprng_draw(dest);

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ extern crate wasm_bindgen;
123123
target_arch = "wasm32",
124124
))]
125125
mod utils;
126-
pub mod error;
127-
126+
mod error;
127+
pub use error::{Error, ERROR_UNKNOWN, ERROR_UNAVAILABLE};
128128

129129
// System-specific implementations.
130130
//

src/linux_android.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Implementation for Linux / Android
1010
extern crate libc;
1111

12-
use error::Error;
12+
use Error;
1313
use utils::use_init;
1414
use std::fs::File;
1515
use std::io;

src/macos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Implementation for MacOS / iOS
1010
extern crate libc;
1111

12-
use error::Error;
12+
use Error;
1313
use std::io;
1414
use std::num::NonZeroU32;
1515
use self::libc::{c_int, size_t};

0 commit comments

Comments
 (0)