From 369d11587339ce74f8ebc76f2607fe55545eaf7d Mon Sep 17 00:00:00 2001 From: garhve Date: Tue, 20 Dec 2022 11:04:25 +0800 Subject: Build small project following the book --- .../target/doc/rand/rngs/adapter/index.html | 5 ++ .../rand/rngs/adapter/read/struct.ReadError.html | 11 ++++ .../doc/rand/rngs/adapter/read/struct.ReadRng.html | 11 ++++ .../adapter/reseeding/struct.ReseedingRng.html | 11 ++++ .../target/doc/rand/rngs/adapter/sidebar-items.js | 1 + .../doc/rand/rngs/adapter/struct.ReadError.html | 8 +++ .../doc/rand/rngs/adapter/struct.ReadRng.html | 17 +++++ .../doc/rand/rngs/adapter/struct.ReseedingRng.html | 61 ++++++++++++++++++ .../guessing_game/target/doc/rand/rngs/index.html | 73 ++++++++++++++++++++++ .../target/doc/rand/rngs/mock/index.html | 3 + .../target/doc/rand/rngs/mock/sidebar-items.js | 1 + .../target/doc/rand/rngs/mock/struct.StepRng.html | 21 +++++++ .../target/doc/rand/rngs/sidebar-items.js | 1 + .../target/doc/rand/rngs/std/struct.StdRng.html | 11 ++++ .../target/doc/rand/rngs/struct.OsRng.html | 27 ++++++++ .../target/doc/rand/rngs/struct.StdRng.html | 19 ++++++ .../target/doc/rand/rngs/struct.ThreadRng.html | 20 ++++++ .../target/doc/rand/rngs/thread/fn.thread_rng.html | 11 ++++ .../doc/rand/rngs/thread/struct.ThreadRng.html | 11 ++++ 19 files changed, 323 insertions(+) create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/index.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadError.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/reseeding/struct.ReseedingRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/sidebar-items.js create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadError.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReseedingRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/index.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/index.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/sidebar-items.js create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/struct.StepRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/sidebar-items.js create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/std/struct.StdRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.OsRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.StdRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.ThreadRng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/fn.thread_rng.html create mode 100644 rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/struct.ThreadRng.html (limited to 'rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs') diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/index.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/index.html new file mode 100644 index 0000000..0851869 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/index.html @@ -0,0 +1,5 @@ +rand::rngs::adapter - Rust
Expand description

Wrappers / adapters forming RNGs

+

Structs

ReadErrorDeprecated
ReadRng error type
ReadRngDeprecated
An RNG that reads random bytes straight from any type supporting +std::io::Read, for example files.
A wrapper around any PRNG that implements BlockRngCore, that adds the +ability to reseed it.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadError.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadError.html new file mode 100644 index 0000000..47e82f7 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadError.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../../rand/rngs/adapter/struct.ReadError.html...

+ + + \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadRng.html new file mode 100644 index 0000000..4b28717 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/read/struct.ReadRng.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../../rand/rngs/adapter/struct.ReadRng.html...

+ + + \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/reseeding/struct.ReseedingRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/reseeding/struct.ReseedingRng.html new file mode 100644 index 0000000..a8ab2b3 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/reseeding/struct.ReseedingRng.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../../rand/rngs/adapter/struct.ReseedingRng.html...

+ + + \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/sidebar-items.js b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/sidebar-items.js new file mode 100644 index 0000000..8c43fd4 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/sidebar-items.js @@ -0,0 +1 @@ +window.SIDEBAR_ITEMS = {"struct":[["ReadError","`ReadRng` error type"],["ReadRng","An RNG that reads random bytes straight from any type supporting [`std::io::Read`], for example files."],["ReseedingRng","A wrapper around any PRNG that implements `BlockRngCore`, that adds the ability to reseed it."]]}; \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadError.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadError.html new file mode 100644 index 0000000..6f8c745 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadError.html @@ -0,0 +1,8 @@ +ReadError in rand::rngs::adapter - Rust
pub struct ReadError(_);
👎Deprecated since 0.8.4
Expand description

ReadRng error type

+

Trait Implementations

Formats the value using the given formatter. Read more
Formats the value using the given formatter. Read more
The lower-level source of this error, if any. Read more
👎Deprecated since 1.42.0: use the Display impl or to_string()
👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
🔬This is a nightly-only experimental API. (provide_any)
Data providers should implement this method to provide all values they are able to +provide by using demand. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadRng.html new file mode 100644 index 0000000..304265d --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReadRng.html @@ -0,0 +1,17 @@ +ReadRng in rand::rngs::adapter - Rust
pub struct ReadRng<R> { /* private fields */ }
👎Deprecated since 0.8.4: removal due to lack of usage
Expand description

An RNG that reads random bytes straight from any type supporting +std::io::Read, for example files.

+

This will work best with an infinite reader, but that is not required.

+

This can be used with /dev/urandom on Unix but it is recommended to use +OsRng instead.

+

Panics

+

ReadRng uses std::io::Read::read_exact, which retries on interrupts. +All other errors from the underlying reader, including when it does not +have enough data, will only be reported through try_fill_bytes. +The other RngCore methods will panic in case of an error.

+

Implementations

Create a new ReadRng from a Read.

+

Trait Implementations

Formats the value using the given formatter. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReseedingRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReseedingRng.html new file mode 100644 index 0000000..132e1d3 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/adapter/struct.ReseedingRng.html @@ -0,0 +1,61 @@ +ReseedingRng in rand::rngs::adapter - Rust
pub struct ReseedingRng<R, Rsdr>(_)
where
    R: BlockRngCore + SeedableRng,
    Rsdr: RngCore
;
Expand description

A wrapper around any PRNG that implements BlockRngCore, that adds the +ability to reseed it.

+

ReseedingRng reseeds the underlying PRNG in the following cases:

+
    +
  • On a manual call to reseed().
  • +
  • After clone(), the clone will be reseeded on first use.
  • +
  • When a process is forked on UNIX, the RNGs in both the parent and child +processes will be reseeded just before the next call to +BlockRngCore::generate, i.e. “soon”. For ChaCha and Hc128 this is a +maximum of fifteen u32 values before reseeding.
  • +
  • After the PRNG has generated a configurable number of random bytes.
  • +
+

When should reseeding after a fixed number of generated bytes be used?

+

Reseeding after a fixed number of generated bytes is never strictly +necessary. Cryptographic PRNGs don’t have a limited number of bytes they +can output, or at least not a limit reachable in any practical way. There is +no such thing as ‘running out of entropy’.

+

Occasionally reseeding can be seen as some form of ‘security in depth’. Even +if in the future a cryptographic weakness is found in the CSPRNG being used, +or a flaw in the implementation, occasionally reseeding should make +exploiting it much more difficult or even impossible.

+

Use ReseedingRng::new with a threshold of 0 to disable reseeding +after a fixed number of generated bytes.

+

Limitations

+

It is recommended that a ReseedingRng (including ThreadRng) not be used +from a fork handler. +Use OsRng or getrandom, or defer your use of the RNG until later.

+

Error handling

+

Although unlikely, reseeding the wrapped PRNG can fail. ReseedingRng will +never panic but try to handle the error intelligently through some +combination of retrying and delaying reseeding until later. +If handling the source error fails ReseedingRng will continue generating +data from the wrapped PRNG without reseeding.

+

Manually calling reseed() will not have this retry or delay logic, but +reports the error.

+

Example

+
use rand::prelude::*;
+use rand_chacha::ChaCha20Core; // Internal part of ChaChaRng that
+                             // implements BlockRngCore
+use rand::rngs::OsRng;
+use rand::rngs::adapter::ReseedingRng;
+
+let prng = ChaCha20Core::from_entropy();
+let mut reseeding_rng = ReseedingRng::new(prng, 0, OsRng);
+
+println!("{}", reseeding_rng.gen::<u64>());
+
+let mut cloned_rng = reseeding_rng.clone();
+assert!(reseeding_rng.gen::<u64>() != cloned_rng.gen::<u64>());
+

Implementations

Create a new ReseedingRng from an existing PRNG, combined with a RNG +to use as reseeder.

+

threshold sets the number of generated bytes after which to reseed the +PRNG. Set it to zero to never reseed based on the number of generated +values.

+

Reseed the internal PRNG.

+

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcast to an RngCore trait object.

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/index.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/index.html new file mode 100644 index 0000000..da55743 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/index.html @@ -0,0 +1,73 @@ +rand::rngs - Rust

Module rand::rngs

source · []
Expand description

Random number generators and adapters

+

Background: Random number generators (RNGs)

+

Computers cannot produce random numbers from nowhere. We classify +random number generators as follows:

+
    +
  • “True” random number generators (TRNGs) use hard-to-predict data sources +(e.g. the high-resolution parts of event timings and sensor jitter) to +harvest random bit-sequences, apply algorithms to remove bias and +estimate available entropy, then combine these bits into a byte-sequence +or an entropy pool. This job is usually done by the operating system or +a hardware generator (HRNG).
  • +
  • “Pseudo”-random number generators (PRNGs) use algorithms to transform a +seed into a sequence of pseudo-random numbers. These generators can be +fast and produce well-distributed unpredictable random numbers (or not). +They are usually deterministic: given algorithm and seed, the output +sequence can be reproduced. They have finite period and eventually loop; +with many algorithms this period is fixed and can be proven sufficiently +long, while others are chaotic and the period depends on the seed.
  • +
  • “Cryptographically secure” pseudo-random number generators (CSPRNGs) +are the sub-set of PRNGs which are secure. Security of the generator +relies both on hiding the internal state and using a strong algorithm.
  • +
+

Traits and functionality

+

All RNGs implement the RngCore trait, as a consequence of which the +Rng extension trait is automatically implemented. Secure RNGs may +additionally implement the CryptoRng trait.

+

All PRNGs require a seed to produce their random number sequence. The +SeedableRng trait provides three ways of constructing PRNGs:

+
    +
  • from_seed accepts a type specific to the PRNG
  • +
  • from_rng allows a PRNG to be seeded from any other RNG
  • +
  • seed_from_u64 allows any PRNG to be seeded from a u64 insecurely
  • +
  • from_entropy securely seeds a PRNG from fresh entropy
  • +
+

Use the rand_core crate when implementing your own RNGs.

+

Our generators

+

This crate provides several random number generators:

+
    +
  • OsRng is an interface to the operating system’s random number +source. Typically the operating system uses a CSPRNG with entropy +provided by a TRNG and some type of on-going re-seeding.
  • +
  • ThreadRng, provided by the thread_rng function, is a handle to a +thread-local CSPRNG with periodic seeding from OsRng. Because this +is local, it is typically much faster than OsRng. It should be +secure, though the paranoid may prefer OsRng.
  • +
  • StdRng is a CSPRNG chosen for good performance and trust of security +(based on reviews, maturity and usage). The current algorithm is ChaCha12, +which is well established and rigorously analysed. +StdRng provides the algorithm used by ThreadRng but without +periodic reseeding.
  • +
  • [SmallRng] is an insecure PRNG designed to be fast, simple, require +little memory, and have good output quality.
  • +
+

The algorithms selected for StdRng and [SmallRng] may change in any +release and may be platform-dependent, therefore they should be considered +not reproducible.

+

Additional generators

+

TRNGs: The rdrand crate provides an interface to the RDRAND and +RDSEED instructions available in modern Intel and AMD CPUs. +The rand_jitter crate provides a user-space implementation of +entropy harvesting from CPU timer jitter, but is very slow and has +security issues.

+

PRNGs: Several companion crates are available, providing individual or +families of PRNG algorithms. These provide the implementations behind +StdRng and [SmallRng] but can also be used directly, indeed should +be used directly when reproducibility matters. +Some suggestions are: rand_chacha, rand_pcg, rand_xoshiro. +A full list can be found by searching for crates with the rng tag.

+

Modules

Wrappers / adapters forming RNGs
Mock random number generator

Structs

A random number generator that retrieves randomness from the +operating system.
The standard RNG. The PRNG algorithm in StdRng is chosen to be efficient +on the current platform, to be statistically strong and unpredictable +(meaning a cryptographically secure PRNG).
A reference to the thread-local generator
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/index.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/index.html new file mode 100644 index 0000000..49b4b05 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/index.html @@ -0,0 +1,3 @@ +rand::rngs::mock - Rust
Expand description

Mock random number generator

+

Structs

A simple implementation of RngCore for testing purposes.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/sidebar-items.js b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/sidebar-items.js new file mode 100644 index 0000000..9d448f0 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/sidebar-items.js @@ -0,0 +1 @@ +window.SIDEBAR_ITEMS = {"struct":[["StepRng","A simple implementation of `RngCore` for testing purposes."]]}; \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/struct.StepRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/struct.StepRng.html new file mode 100644 index 0000000..45140c5 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/mock/struct.StepRng.html @@ -0,0 +1,21 @@ +StepRng in rand::rngs::mock - Rust
pub struct StepRng { /* private fields */ }
Expand description

A simple implementation of RngCore for testing purposes.

+

This generates an arithmetic sequence (i.e. adds a constant each step) +over a u64 number, using wrapping arithmetic. If the increment is 0 +the generator yields a constant.

+ +
use rand::Rng;
+use rand::rngs::mock::StepRng;
+
+let mut my_rng = StepRng::new(2, 1);
+let sample: [u64; 3] = my_rng.gen();
+assert_eq!(sample, [2, 3, 4]);
+

Implementations

Create a StepRng, yielding an arithmetic sequence starting with +initial and incremented by increment each time.

+

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used +by ==. Read more
This method tests for !=. The default implementation is almost always +sufficient, and should not be overridden without very good reason. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/sidebar-items.js b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/sidebar-items.js new file mode 100644 index 0000000..3c82c8d --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/sidebar-items.js @@ -0,0 +1 @@ +window.SIDEBAR_ITEMS = {"mod":[["adapter","Wrappers / adapters forming RNGs"],["mock","Mock random number generator"]],"struct":[["OsRng","A random number generator that retrieves randomness from the operating system."],["StdRng","The standard RNG. The PRNG algorithm in `StdRng` is chosen to be efficient on the current platform, to be statistically strong and unpredictable (meaning a cryptographically secure PRNG)."],["ThreadRng","A reference to the thread-local generator"]]}; \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/std/struct.StdRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/std/struct.StdRng.html new file mode 100644 index 0000000..6b6b668 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/std/struct.StdRng.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../rand/rngs/struct.StdRng.html...

+ + + \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.OsRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.OsRng.html new file mode 100644 index 0000000..821dd5f --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.OsRng.html @@ -0,0 +1,27 @@ +OsRng in rand::rngs - Rust
pub struct OsRng;
Expand description

A random number generator that retrieves randomness from the +operating system.

+

This is a zero-sized struct. It can be freely constructed with OsRng.

+

The implementation is provided by the getrandom crate. Refer to +getrandom documentation for details.

+

This struct is only available when specifying the crate feature getrandom +or std. When using the rand lib, it is also available as rand::rngs::OsRng.

+

Blocking and error handling

+

It is possible that when used during early boot the first call to OsRng +will block until the system’s RNG is initialised. It is also possible +(though highly unlikely) for OsRng to fail on some platforms, most +likely due to system mis-configuration.

+

After the first successful call, it is highly unlikely that failures or +significant delays will occur (although performance should be expected to +be much slower than a user-space PRNG).

+

Usage example

+
use rand_core::{RngCore, OsRng};
+
+let mut key = [0u8; 16];
+OsRng.fill_bytes(&mut key);
+let random_u64 = OsRng.next_u64();
+

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcast to an RngCore trait object.

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.StdRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.StdRng.html new file mode 100644 index 0000000..5faf216 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.StdRng.html @@ -0,0 +1,19 @@ +StdRng in rand::rngs - Rust
pub struct StdRng(_);
Expand description

The standard RNG. The PRNG algorithm in StdRng is chosen to be efficient +on the current platform, to be statistically strong and unpredictable +(meaning a cryptographically secure PRNG).

+

The current algorithm used is the ChaCha block cipher with 12 rounds. Please +see this relevant rand issue for the discussion. This may change as new +evidence of cipher security and performance becomes available.

+

The algorithm is deterministic but should not be considered reproducible +due to dependence on configuration and possible replacement in future +library versions. For a secure reproducible generator, we recommend use of +the rand_chacha crate directly.

+

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used +by ==. Read more
This method tests for !=. The default implementation is almost always +sufficient, and should not be overridden without very good reason. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more
Seed type, which is restricted to types mutably-dereferenceable as u8 +arrays (we recommend [u8; N] for some N). Read more
Create a new PRNG using the given seed. Read more
Create a new PRNG seeded from another Rng. Read more
Create a new PRNG using a u64 seed. Read more
Creates a new instance of the RNG seeded via getrandom. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcast to an RngCore trait object.

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.ThreadRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.ThreadRng.html new file mode 100644 index 0000000..f2e6783 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/struct.ThreadRng.html @@ -0,0 +1,20 @@ +ThreadRng in rand::rngs - Rust
pub struct ThreadRng { /* private fields */ }
Expand description

A reference to the thread-local generator

+

An instance can be obtained via thread_rng or via ThreadRng::default(). +This handle is safe to use everywhere (including thread-local destructors), +though it is recommended not to use inside a fork handler. +The handle cannot be passed between threads (is not Send or Sync).

+

ThreadRng uses the same PRNG as StdRng for security and performance +and is automatically seeded from OsRng.

+

Unlike StdRng, ThreadRng uses the ReseedingRng wrapper to reseed +the PRNG from fresh entropy every 64 kiB of random data as well as after a +fork on Unix (though not quite immediately; see documentation of +ReseedingRng). +Note that the reseeding is done as an extra precaution against side-channel +attacks and mis-use (e.g. if somehow weak entropy were supplied initially). +The PRNG algorithms used are assumed to be secure.

+

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Return the next random u32. Read more
Return the next random u64. Read more
Fill dest with random data. Read more
Fill dest entirely with random data. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Upcast to an RngCore trait object.

Returns the argument unchanged.

+

Calls U::from(self).

+

That is, this conversion is whatever the implementation of +From<T> for U chooses to do.

+
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
\ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/fn.thread_rng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/fn.thread_rng.html new file mode 100644 index 0000000..fd6b38f --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/fn.thread_rng.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../rand/fn.thread_rng.html...

+ + + \ No newline at end of file diff --git a/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/struct.ThreadRng.html b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/struct.ThreadRng.html new file mode 100644 index 0000000..f055ab8 --- /dev/null +++ b/rust/theBook/chapter-2-guessing-game/guessing_game/target/doc/rand/rngs/thread/struct.ThreadRng.html @@ -0,0 +1,11 @@ + + + + + Redirection + + +

Redirecting to ../../../rand/rngs/struct.ThreadRng.html...

+ + + \ No newline at end of file -- cgit v1.2.3-70-g09d2