Skip to content

Commit ff80c0c

Browse files
committed
Add Custom RNG: getrandom-dummy
1 parent 6592598 commit ff80c0c

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ appveyor = { repository = "rust-random/getrandom" }
1616

1717
[workspace]
1818
members = [
19+
"custom/dummy",
1920
]
2021

2122
[dependencies]

custom/dummy/Cargo.toml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "getrandom-dummy"
3+
version = "0.1.0"
4+
edition = "2018"
5+
authors = ["The Rand Project Developers"]
6+
license = "MIT OR Apache-2.0"
7+
description = "Dummy implementation for using getrandom on all unsupported targets"
8+
documentation = "https://docs.rs/getrandom-dummy"
9+
repository = "https://github.com/rust-random/getrandom/tree/master/custom/dummy"
10+
11+
[lib]
12+
crate-type = ["dylib"]
13+
14+
[dependencies]
15+
getrandom = { path = "../..", features = ["custom"] }

custom/dummy/src/lib.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 Developers of the Rand project.
2+
//
3+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4+
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5+
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6+
// option. This file may not be copied, modified, or distributed
7+
// except according to those terms.
8+
9+
//! `getrandom` dummy implementation for all unsupported targets
10+
use getrandom::{register_custom_getrandom, Error};
11+
12+
register_custom_getrandom!(getrandom_inner);
13+
14+
fn getrandom_inner(_dest: &mut [u8]) -> Result<(), Error> {
15+
Err(Error::UNSUPPORTED)
16+
}

0 commit comments

Comments
 (0)