-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41559f0
commit 1587eee
Showing
4 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/// A small module that makes get_random work on wasm32-unknown-unknown. | ||
/// The dependency on get_random comes from the captcha library. | ||
#[cfg(all( | ||
target_arch = "wasm32", | ||
target_vendor = "unknown", | ||
target_os = "unknown" | ||
))] | ||
mod wasm_get_random; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! This module exists to work around a problem with `getrandom` 0.2, which is a dependency | ||
//! of `rand` 0.8 | ||
//! | ||
//! For the `wasm32-unknown-unknown` target, `getrandom` 0.2 will refuse to compile. This is an | ||
//! intentional policy decision on the part of the getrandom developers. As a consequence, it | ||
//! would not be possible to compile anything which depends on `rand` 0.8 to wasm for use in | ||
//! canister code. | ||
//! | ||
//! Depending on this crate converts the compile time error into a runtime error, by | ||
//! registering a custom `getrandom` implementation which always fails. This matches the | ||
//! behavior of `getrandom` 0.1. | ||
//! | ||
//! See the [getrandom | ||
//! documentation](https://docs.rs/getrandom/latest/getrandom/macro.register_custom_getrandom.html) | ||
//! for more details on custom implementations. | ||
|
||
/// A getrandom implementation that always fails | ||
pub fn always_fail(_buf: &mut [u8]) -> Result<(), getrandom::Error> { | ||
Err(getrandom::Error::UNSUPPORTED) | ||
} | ||
getrandom::register_custom_getrandom!(always_fail); |