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};

src/netbsd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
//! Implementation for NetBSD
1010
11-
use error::Error;
11+
use Error;
1212
use utils::use_init;
1313
use std::fs::File;
1414
use std::io::Read;

src/openbsd_bitrig.rs

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

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

src/redox.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 Redox
10-
use error::Error;
10+
use Error;
1111
use utils::use_init;
1212
use std::fs::File;
1313
use std::io::Read;

src/sgx.rs

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

99
//! Implementation for SGX using RDRAND instruction
10-
use error::{Error, UNKNOWN};
10+
use {Error, ERROR_UNKNOWN};
1111

1212
use core::{mem, ptr};
1313
use core::arch::x86_64::_rdrand64_step;
@@ -27,7 +27,7 @@ fn get_rand_u64() -> Result<u64, Error> {
2727
}
2828
};
2929
}
30-
Err(UNKNOWN)
30+
Err(ERROR_UNKNOWN)
3131
}
3232

3333
pub fn getrandom_inner(mut dest: &mut [u8]) -> Result<(), Error> {

src/solarish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! libc::dlsym.
2020
extern crate libc;
2121

22-
use error::Error;
22+
use Error;
2323
use std::cell::RefCell;
2424
use std::fs::File;
2525
use std::io;

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
8-
use error::Error;
8+
use Error;
99
use core::cell::RefCell;
1010
use core::ops::DerefMut;
1111

src/wasm32_bindgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::num::NonZeroU32;
1515
use wasm_bindgen::prelude::*;
1616

1717
use __wbg_shims::*;
18-
use error::Error;
18+
use Error;
1919
use utils::use_init;
2020

2121
const CODE_PREFIX: u32 = ::error::CODE_PREFIX | 0x8e00;

src/wasm32_stdweb.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::num::NonZeroU32;
1515
use stdweb::unstable::TryInto;
1616
use stdweb::web::error::Error as WebError;
1717

18-
use error::{Error, UNAVAILABLE, UNKNOWN};
18+
use {Error, ERROR_UNAVAILABLE, ERROR_UNKNOWN};
1919
use utils::use_init;
2020

2121
#[derive(Clone, Debug)]
@@ -66,7 +66,7 @@ fn getrandom_init() -> Result<RngSource, Error> {
6666
else { unreachable!() }
6767
} else {
6868
let err: WebError = js!{ return @{ result }.error }.try_into().unwrap();
69-
Err(UNAVAILABLE) // TODO: forward err
69+
Err(ERROR_UNAVAILABLE) // TODO: forward err
7070
}
7171
}
7272

@@ -101,7 +101,7 @@ fn getrandom_fill(source: &mut RngSource, dest: &mut [u8]) -> Result<(), Error>
101101

102102
if js!{ return @{ result.as_ref() }.success } != true {
103103
let err: WebError = js!{ return @{ result }.error }.try_into().unwrap();
104-
return Err(UNKNOWN) // TODO: forward err
104+
return Err(ERROR_UNKNOWN) // TODO: forward err
105105
}
106106
}
107107
Ok(())

src/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use self::winapi::um::ntsecapi::RtlGenRandom;
1414
use self::winapi::um::winnt::PVOID;
1515
use std::io;
1616
use std::num::NonZeroU32;
17-
use error::Error;
17+
use Error;
1818

1919
pub fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
2020
let ret = unsafe {

0 commit comments

Comments
 (0)