|
61 | 61 | //! `wasm32-unknown-emscripten` and `wasm32-experimental-emscripten` use |
62 | 62 | //! Emscripten's emulation of `/dev/random` on web browsers and Node.js. |
63 | 63 | //! |
64 | | -//! The bare Wasm target `wasm32-unknown-unknown` tries to call the javascript |
| 64 | +//! The bare WASM target `wasm32-unknown-unknown` tries to call the javascript |
65 | 65 | //! methods directly, using either `stdweb` or `wasm-bindgen` depending on what |
66 | 66 | //! features are activated for this crate. Note that if both features are |
67 | 67 | //! enabled `wasm-bindgen` will be used. |
|
87 | 87 | //! `/dev/random` until we know the OS RNG is initialized (and store this in a |
88 | 88 | //! global static). |
89 | 89 | //! |
90 | | -//! # Panics |
| 90 | +//! # Panics and error handling |
91 | 91 | //! |
92 | | -//! `OsRng` is extremely unlikely to fail if `OsRng::new()`, and one read from |
93 | | -//! it, where succesfull. But in case it does fail, only [`try_fill_bytes`] is |
94 | | -//! able to report the cause. Depending on the error the other [`RngCore`] |
95 | | -//! methods will retry several times, and panic in case the error remains. |
| 92 | +//! We cannot guarantee that `OsRng` will fail, but if it does, it will likely |
| 93 | +//! be either when `OsRng::new()` is first called or when data is first read. |
| 94 | +//! If you wish to catch errors early, then test reading of at least one byte |
| 95 | +//! from `OsRng` via [`try_fill_bytes`]. If this succeeds, it is extremely |
| 96 | +//! unlikely that any further errors will occur. |
| 97 | +//! |
| 98 | +//! Only [`try_fill_bytes`] is able to report the cause of an error; the other |
| 99 | +//! [`RngCore`] methods may (depending on the error kind) retry several times, |
| 100 | +//! but must eventually panic if the error persists. |
96 | 101 | //! |
97 | 102 | //! [`EntropyRng`]: ../rand/rngs/struct.EntropyRng.html |
98 | 103 | //! [`RngCore`]: ../rand_core/trait.RngCore.html |
|
0 commit comments