1# rand_core 2 3[![Test Status](https://github.com/rust-random/rand/workflows/Tests/badge.svg?event=push)](https://github.com/rust-random/rand/actions) 4[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core) 5[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/) 6[![API](https://img.shields.io/badge/api-master-yellow.svg)](https://rust-random.github.io/rand/rand_core) 7[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core) 8[![Minimum rustc version](https://img.shields.io/badge/rustc-1.36+-lightgray.svg)](https://github.com/rust-random/rand#rust-version-requirements) 9 10Core traits and error types of the [rand] library, plus tools for implementing 11RNGs. 12 13This crate is intended for use when implementing the core trait, `RngCore`; it 14defines the core traits to be implemented as well as several small functions to 15aid in their implementation and types required for error handling. 16 17The main [rand] crate re-exports most items defined in this crate, along with 18tools to convert the integer samples generated by `RngCore` to many different 19applications (including sampling from restricted ranges, conversion to floating 20point, list permutations and secure initialisation of RNGs). Most users should 21prefer to use the main [rand] crate. 22 23Links: 24 25- [API documentation (master)](https://rust-random.github.io/rand/rand_core) 26- [API documentation (docs.rs)](https://docs.rs/rand_core) 27- [Changelog](https://github.com/rust-random/rand/blob/master/rand_core/CHANGELOG.md) 28 29[rand]: https://crates.io/crates/rand 30 31 32## Functionality 33 34The `rand_core` crate provides: 35 36- base random number generator traits 37- error-reporting types 38- functionality to aid implementation of RNGs 39 40The traits and error types are also available via `rand`. 41 42## Versions 43 44The current version is: 45``` 46rand_core = "0.6.0" 47``` 48 49Rand libs have inter-dependencies and make use of the 50[semver trick](https://github.com/dtolnay/semver-trick/) in order to make traits 51compatible across crate versions. (This is especially important for `RngCore` 52and `SeedableRng`.) A few crate releases are thus compatibility shims, 53depending on the *next* lib version (e.g. `rand_core` versions `0.2.2` and 54`0.3.1`). This means, for example, that `rand_core_0_4_0::SeedableRng` and 55`rand_core_0_3_0::SeedableRng` are distinct, incompatible traits, which can 56cause build errors. Usually, running `cargo update` is enough to fix any issues. 57 58## Crate Features 59 60`rand_core` supports `no_std` and `alloc`-only configurations, as well as full 61`std` functionality. The differences between `no_std` and full `std` are small, 62comprising `RngCore` support for `Box<R>` types where `R: RngCore`, 63`std::io::Read` support for types supporting `RngCore`, and 64extensions to the `Error` type's functionality. 65 66The `std` feature is *not enabled by default*. This is primarily to avoid build 67problems where one crate implicitly requires `rand_core` with `std` support and 68another crate requires `rand` *without* `std` support. However, the `rand` crate 69continues to enable `std` support by default, both for itself and `rand_core`. 70 71The `serde1` feature can be used to derive `Serialize` and `Deserialize` for RNG 72implementations that use the `BlockRng` or `BlockRng64` wrappers. 73 74 75# License 76 77`rand_core` is distributed under the terms of both the MIT license and the 78Apache License (Version 2.0). 79 80See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and 81[COPYRIGHT](COPYRIGHT) for details. 82