|
|
|
|
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `RngCore` trait in crate `rand`."><meta name="keywords" content="rust, rustlang, rust-lang, RngCore"><title>rand::RngCore - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="https://www.rust-lang.org/favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../rand/index.html'><div class='logo-container'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk.png' alt='logo'></div></a><p class='location'>Trait RngCore</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.fill_bytes">fill_bytes</a><a href="#tymethod.next_u32">next_u32</a><a href="#tymethod.next_u64">next_u64</a><a href="#tymethod.try_fill_bytes">try_fill_bytes</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-RngCore-for-%26%27a%20mut%20R">&'a mut R</a><a href="#impl-RngCore-for-BlockRng%3CR%3E">BlockRng<R></a><a href="#impl-RngCore-for-BlockRng64%3CR%3E">BlockRng64<R></a><a href="#impl-RngCore-for-Box%3CR%3E">Box<R></a><a href="#impl-RngCore-for-ChaChaRng">ChaChaRng</a><a href="#impl-RngCore-for-Hc128Rng">Hc128Rng</a><a href="#impl-RngCore-for-Isaac64Rng">Isaac64Rng</a><a href="#impl-RngCore-for-IsaacRng">IsaacRng</a><a href="#impl-RngCore-for-Lcg64Xsh32">Lcg64Xsh32</a><a href="#impl-RngCore-for-Mcg128Xsl64">Mcg128Xsl64</a><a href="#impl-RngCore-for-XorShiftRng">XorShiftRng</a></div><a class="sidebar-title" href="#implementors">Implementors</a><a class="sidebar-title" href="#implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-Read">Read</a></div></div><p class='location'><a href='index.html'>rand</a></p><script>window.sidebarCurrent = {name: 'RngCore', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/rand_core/lib.rs.html#138-185' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='index.html'>rand</a>::<wbr><a class="trait" href=''>RngCore</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait RngCore {
|
|
|
|
|
fn <a href='#tymethod.next_u32' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>;
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#tymethod.next_u64' class='fnname'>next_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>;
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#tymethod.fill_bytes' class='fnname'>fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>);
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#tymethod.try_fill_bytes' class='fnname'>try_fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../rand/struct.Error.html" title="struct rand::Error">Error</a>>;
|
|
|
|
|
}</pre></div><div class='docblock'><p>The core of a random number generator.</p>
|
|
|
|
|
<p>This trait encapsulates the low-level functionality common to all
|
|
|
|
|
generators, and is the "back end", to be implemented by generators.
|
|
|
|
|
End users should normally use the <code>Rng</code> trait from the <a href="https://docs.rs/rand"><code>rand</code></a> crate,
|
|
|
|
|
which is automatically implemented for every type implementing <code>RngCore</code>.</p>
|
|
|
|
|
<p>Three different methods for generating random data are provided since the
|
|
|
|
|
optimal implementation of each is dependent on the type of generator. There
|
|
|
|
|
is no required relationship between the output of each; e.g. many
|
|
|
|
|
implementations of <a href="RngCore::fill_bytes"><code>fill_bytes</code></a> consume a whole number of <code>u32</code> or <code>u64</code>
|
|
|
|
|
values and drop any remaining unused bytes.</p>
|
|
|
|
|
<p>The <a href="RngCore::try_fill_bytes"><code>try_fill_bytes</code></a> method is a variant of <a href="RngCore::fill_bytes"><code>fill_bytes</code></a> allowing error
|
|
|
|
|
handling; it is not deemed sufficiently useful to add equivalents for
|
|
|
|
|
<a href="RngCore::next_u32"><code>next_u32</code></a> or <a href="RngCore::next_u64"><code>next_u64</code></a> since the latter methods are almost always used
|
|
|
|
|
with algorithmic generators (PRNGs), which are normally infallible.</p>
|
|
|
|
|
<p>Algorithmic generators implementing [<code>SeedableRng</code>] should normally have
|
|
|
|
|
<em>portable, reproducible</em> output, i.e. fix Endianness when converting values
|
|
|
|
|
to avoid platform differences, and avoid making any changes which affect
|
|
|
|
|
output (except by communicating that the release has breaking changes).</p>
|
|
|
|
|
<p>Typically implementators will implement only one of the methods available
|
|
|
|
|
in this trait directly, then use the helper functions from the
|
|
|
|
|
[<code>impls</code>] module to implement the other methods.</p>
|
|
|
|
|
<p>It is recommended that implementations also implement:</p>
|
|
|
|
|
<ul>
|
|
|
|
|
<li><code>Debug</code> with a custom implementation which <em>does not</em> print any internal
|
|
|
|
|
state (at least, [<code>CryptoRng</code>]s should not risk leaking state through
|
|
|
|
|
<code>Debug</code>).</li>
|
|
|
|
|
<li><code>Serialize</code> and <code>Deserialize</code> (from Serde), preferably making Serde
|
|
|
|
|
support optional at the crate level in PRNG libs.</li>
|
|
|
|
|
<li><code>Clone</code>, if possible.</li>
|
|
|
|
|
<li><em>never</em> implement <code>Copy</code> (accidental copies may cause repeated values).</li>
|
|
|
|
|
<li><em>do not</em> implement <code>Default</code> for pseudorandom generators, but instead
|
|
|
|
|
implement [<code>SeedableRng</code>], to guide users towards proper seeding.
|
|
|
|
|
External / hardware RNGs can choose to implement <code>Default</code>.</li>
|
|
|
|
|
<li><code>Eq</code> and <code>PartialEq</code> could be implemented, but are probably not useful.</li>
|
|
|
|
|
</ul>
|
|
|
|
|
<h1 id="example" class="section-header"><a href="#example">Example</a></h1>
|
|
|
|
|
<p>A simple example, obviously not generating very <em>random</em> output:</p>
|
|
|
|
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
|
|
<span class="attribute">#![<span class="ident">allow</span>(<span class="ident">dead_code</span>)]</span>
|
|
|
|
|
<span class="kw">use</span> <span class="ident">rand_core</span>::{<span class="ident">RngCore</span>, <span class="ident">Error</span>, <span class="ident">impls</span>};
|
|
|
|
|
|
|
|
|
|
<span class="kw">struct</span> <span class="ident">CountingRng</span>(<span class="ident">u64</span>);
|
|
|
|
|
|
|
|
|
|
<span class="kw">impl</span> <span class="ident">RngCore</span> <span class="kw">for</span> <span class="ident">CountingRng</span> {
|
|
|
|
|
<span class="kw">fn</span> <span class="ident">next_u32</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">></span> <span class="ident">u32</span> {
|
|
|
|
|
<span class="self">self</span>.<span class="ident">next_u64</span>() <span class="kw">as</span> <span class="ident">u32</span>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<span class="kw">fn</span> <span class="ident">next_u64</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-</span><span class="op">></span> <span class="ident">u64</span> {
|
|
|
|
|
<span class="self">self</span>.<span class="number">0</span> <span class="op">+</span><span class="op">=</span> <span class="number">1</span>;
|
|
|
|
|
<span class="self">self</span>.<span class="number">0</span>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<span class="kw">fn</span> <span class="ident">fill_bytes</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">dest</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> [<span class="ident">u8</span>]) {
|
|
|
|
|
<span class="ident">impls</span>::<span class="ident">fill_bytes_via_next</span>(<span class="self">self</span>, <span class="ident">dest</span>)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<span class="kw">fn</span> <span class="ident">try_fill_bytes</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="self">self</span>, <span class="ident">dest</span>: <span class="kw-2">&</span><span class="kw-2">mut</span> [<span class="ident">u8</span>]) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span>(), <span class="ident">Error</span><span class="op">></span> {
|
|
|
|
|
<span class="prelude-val">Ok</span>(<span class="self">self</span>.<span class="ident">fill_bytes</span>(<span class="ident">dest</span>))
|
|
|
|
|
}
|
|
|
|
|
}</pre></div>
|
|
|
|
|
</div>
|
|
|
|
|
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.next_u32' class='method'><code id='next_u32.v'>fn <a href='#tymethod.next_u32' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code></h3><div class='docblock'><p>Return the next random <code>u32</code>.</p>
|
|
|
|
|
<p>RNGs must implement at least one method from this trait directly. In
|
|
|
|
|
the case this method is not implemented directly, it can be implemented
|
|
|
|
|
using <code>self.next_u64() as u32</code> or via
|
|
|
|
|
[<code>fill_bytes</code>][impls::next_u32_via_fill].</p>
|
|
|
|
|
</div><h3 id='tymethod.next_u64' class='method'><code id='next_u64.v'>fn <a href='#tymethod.next_u64' class='fnname'>next_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code></h3><div class='docblock'><p>Return the next random <code>u64</code>.</p>
|
|
|
|
|
<p>RNGs must implement at least one method from this trait directly. In
|
|
|
|
|
the case this method is not implemented directly, it can be implemented
|
|
|
|
|
via [<code>next_u32</code>][impls::next_u64_via_u32] or via
|
|
|
|
|
[<code>fill_bytes</code>][impls::next_u64_via_fill].</p>
|
|
|
|
|
</div><h3 id='tymethod.fill_bytes' class='method'><code id='fill_bytes.v'>fn <a href='#tymethod.fill_bytes' class='fnname'>fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></h3><div class='docblock'><p>Fill <code>dest</code> with random data.</p>
|
|
|
|
|
<p>RNGs must implement at least one method from this trait directly. In
|
|
|
|
|
the case this method is not implemented directly, it can be implemented
|
|
|
|
|
via [<code>next_u*</code>][impls::fill_bytes_via_next] or
|
|
|
|
|
via [<code>try_fill_bytes</code>][RngCore::try_fill_bytes]; if this generator can
|
|
|
|
|
fail the implementation must choose how best to handle errors here
|
|
|
|
|
(e.g. panic with a descriptive message or log a warning and retry a few
|
|
|
|
|
times).</p>
|
|
|
|
|
<p>This method should guarantee that <code>dest</code> is entirely filled
|
|
|
|
|
with new data, and may panic if this is impossible
|
|
|
|
|
(e.g. reading past the end of a file that is being used as the
|
|
|
|
|
source of randomness).</p>
|
|
|
|
|
</div><h3 id='tymethod.try_fill_bytes' class='method'><code id='try_fill_bytes.v'>fn <a href='#tymethod.try_fill_bytes' class='fnname'>try_fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../rand/struct.Error.html" title="struct rand::Error">Error</a>></code></h3><div class='docblock'><p>Fill <code>dest</code> entirely with random data.</p>
|
|
|
|
|
<p>This is the only method which allows an RNG to report errors while
|
|
|
|
|
generating random data thus making this the primary method implemented
|
|
|
|
|
by external (true) RNGs (e.g. <code>OsRng</code>) which can fail. It may be used
|
|
|
|
|
directly to generate keys and to seed (infallible) PRNGs.</p>
|
|
|
|
|
<p>Other than error handling, this method is identical to <a href="RngCore::fill_bytes"><code>fill_bytes</code></a>;
|
|
|
|
|
thus this may be implemented using <code>Ok(self.fill_bytes(dest))</code> or
|
|
|
|
|
<code>fill_bytes</code> may be implemented with
|
|
|
|
|
<code>self.try_fill_bytes(dest).unwrap()</code> or more specific error handling.</p>
|
|
|
|
|
</div></div><span class='loading-content'>Loading content...</span><h2 id='implementations' class='small-section-header'>Trait Implementations<a href='#implementations' class='anchor'></a></h2><div id='implementations-list'><h3 id='impl-Read' class='impl'><code class='in-band'>impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> for dyn <a class="trait" href="../rand/trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + 'static</code><a href='#impl-Read' class='anchor'></a><a class='srclink' href='../src/rand_core/lib.rs.html#422-427' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.read' class="method hidden"><code id='read.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read' class='fnname'>read</a>(&mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></code><a class='srclink' href='../src/rand_core/lib.rs.html#423-426' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Pull some bytes from this source into the specified buffer, returning how many bytes were read. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#tymethod.read">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.read_vectored' class="method hidden"><code id='read_vectored.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_vectored' class='fnname'>read_vectored</a>(&mut self, bufs: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.IoSliceMut.html" title="struct std::io::IoSliceMut">IoSliceMut</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></code><span class='since' title='Stable since Rust version 1.36.0'>1.36.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#580-582' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Like <code>read</code>, except that it reads into a slice of buffers. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_vectored">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.initializer' class="method hidden"><code id='initializer.v'>unsafe fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.initializer' class='fnname'>initializer</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Initializer.html" title="struct std::io::Initializer">Initializer</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#608-610' title='goto source code'>[src]</a></h4><div class='stability hidden'><div class='stab unstable'><span class='emoji'>🔬</span> This is a nightly-only experimental API. (<code>read_initializer</code>)</div></div><div class='docblock hidden'><p>Determines if this <code>Read</code>er can work with buffers of uninitialized memory. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.initializer">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.read_to_end' class="method hidden"><code id='read_to_end.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_end' class='fnname'>read_to_end</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#660-662' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Read all bytes until EOF in this source, placing them into <code>buf</code>. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_end">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.read_to_string' class="method hidden"><code id='read_to_string.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_string' class='fnname'>read_to_string</a>(&mut self, buf: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#703-714' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Read all bytes until EOF in this source, appending them to <code>buf</code>. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_to_string">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.read_exact' class="method hidden"><code id='read_exact.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_exact' class='fnname'>read_exact</a>(&mut self, buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></code><span class='since' title='Stable since Rust version 1.6.0'>1.6.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#766-781' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Read the exact number of bytes required to fill <code>buf</code>. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.read_exact">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.by_ref' class="method hidden"><code id='by_ref.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.by_ref' class='fnname'>by_ref</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut </a>Self</code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#818' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates a "by reference" adaptor for this instance of <code>Read</code>. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.by_ref">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.bytes' class="method hidden"><code id='bytes.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes' class='fnname'>bytes</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Bytes.html" title="struct std::io::Bytes">Bytes</a><Self></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#855-857' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Transforms this <code>Read</code> instance to an [<code>Iterator</code>] over its bytes. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.bytes">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.chain' class="method hidden"><code id='chain.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain' class='fnname'>chain</a><R>(self, next: R) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Chain.html" title="struct std::io::Chain">Chain</a><Self, R> <span class="where fmt-newline">where<br> R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a>, </span></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#890-892' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates an adaptor which will chain this stream with another. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.chain">Read more</a></p>
|
|
|
|
|
</div><h4 id='method.take' class="method hidden"><code id='take.v'>fn <a href='https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.take' class='fnname'>take</a>(self, limit: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/struct.Take.html" title="struct std::io::Take">Take</a><Self></code><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#926-928' title='goto source code'>[src]</a></h4><div class='docblock hidden'><p>Creates an adaptor which will read at most <code>limit</code> bytes from it. <a href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html#method.take">Read more</a></p>
|
|
|
|
|
</div></div></div>
|
|
|
|
|
<h2 id='foreign-impls' class='small-section-header'>Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a></h2><h3 id='impl-RngCore-for-Box%3CR%3E' class='impl'><code class='in-band'>impl<R> <a class="trait" href="../rand/trait.RngCore.html" title="trait rand::RngCore">RngCore</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><R> <span class="where fmt-newline">where<br> R: <a class="trait" href="../rand/trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-RngCore-for-Box%3CR%3E' class='anchor'></a><a class='srclink' href='../src/rand_core/lib.rs.html#399-419' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.next_u32' class="method hidden"><code id='next_u32.v-1'>fn <a href='#method.next_u32' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../src/rand_core/lib.rs.html#401-403' title='goto source code'>[src]</a></h4><h4 id='method.next_u64' class="method hidden"><code id='next_u64.v-1'>fn <a href='#method.next_u64' class='fnname'>next_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../src/rand_core/lib.rs.html#406-408' title='goto source code'>[src]</a></h4><h4 id='method.fill_bytes' class="method hidden"><code id='fill_bytes.v-1'>fn <a href='#method.fill_bytes' class='fnname'>fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code><a class='srclink' href='../src/rand_core/lib.rs.html#411-413' title='goto source code'>[src]</a></h4><h4 id='method.try_fill_bytes' class="method hidden"><code id='try_fill_bytes.v-1'>fn <a href='#method.try_fill_bytes' class='fnname'>try_fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../rand/struct.Error.html" title="struct rand::Error">Error</a>></code><a class='srclink' href='../src/rand_core/lib.rs.html#416-418' title='goto source code'>[src]</a></h4></div><h3 id='impl-RngCore-for-%26%27a%20mut%20R' class='impl'><code class='in-band'>impl<'a, R> <a class="trait" href="../rand/trait.RngCore.html" title="trait rand::RngCore">RngCore</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&'a mut </a>R <span class="where fmt-newline">where<br> R: <a class="trait" href="../rand/trait.RngCore.html" title="trait rand::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, </span></code><a href='#impl-RngCore-for-%26%27a%20mut%20R' class='anchor'></a><a class='srclink' href='../src/rand_core/lib.rs.html#373-393' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.next_u32-1' class="method hidden"><code id='next_u32.v-2'>fn <a href='#method.next_u32' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href=
|
|
|
|
|
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'><h3 id='impl-RngCore' class='impl'><code class='in-band'>impl RngCore for <a class="struct" href="../rand/rngs/mock/struct.StepRng.html" title="struct rand::rngs::mock::StepRng">StepRng</a></code><a href='#impl-RngCore' class='anchor'></a><a class='srclink' href='../src/rand/rngs/mock.rs.html#41-59' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.next_u32-11' class="method hidden"><code id='next_u32.v-12'>fn <a href='#method.next_u32-11' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../src/rand/rngs/mock.rs.html#42-44' title='goto source code'>[src]</a></h4><h4 id='method.next_u64-11' class="method hidden"><code id='next_u64.v-12'>fn <a href='#method.next_u64-11' class='fnname'>next_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../src/rand/rngs/mock.rs.html#46-50' title='goto source code'>[src]</a></h4><h4 id='method.fill_bytes-11' class="method hidden"><code id='fill_bytes.v-12'>fn <a href='#method.fill_bytes-11' class='fnname'>fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code><a class='srclink' href='../src/rand/rngs/mock.rs.html#52-54' title='goto source code'>[src]</a></h4><h4 id='method.try_fill_bytes-11' class="method hidden"><code id='try_fill_bytes.v-12'>fn <a href='#method.try_fill_bytes-11' class='fnname'>try_fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="../rand/struct.Error.html" title="struct rand::Error">Error</a>></code><a class='srclink' href='../src/rand/rngs/mock.rs.html#56-58' title='goto source code'>[src]</a></h4></div><h3 id='impl-RngCore-1' class='impl'><code class='in-band'>impl RngCore for <a class="struct" href="../rand/rngs/struct.EntropyRng.html" title="struct rand::rngs::EntropyRng">EntropyRng</a></code><a href='#impl-RngCore-1' class='anchor'></a><a class='srclink' href='../src/rand/rngs/entropy.rs.html#75-160' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.next_u32-12' class="method hidden"><code id='next_u32.v-13'>fn <a href='#method.next_u32-12' class='fnname'>next_u32</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a></code><a class='srclink' href='../src/rand/rngs/entropy.rs.html#76-78' title='goto source code'>[src]</a></h4><h4 id='method.next_u64-12' class="method hidden"><code id='next_u64.v-13'>fn <a href='#method.next_u64-12' class='fnname'>next_u64</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a></code><a class='srclink' href='../src/rand/rngs/entropy.rs.html#80-82' title='goto source code'>[src]</a></h4><h4 id='method.fill_bytes-12' class="method hidden"><code id='fill_bytes.v-13'>fn <a href='#method.fill_bytes-12' class='fnname'>fill_bytes</a>(&mut self, dest: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="htt
|
|
|
|
|
src="../implementors/rand_core/trait.RngCore.js">
|
|
|
|
|
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "rand";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>
|