mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-19 00:59:52 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
1
rand_core/all.html
Normal file
1
rand_core/all.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
<!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="List of all items in this crate"><title>List of all items in this crate</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod sys"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h3><a href="#structs">Crate Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><h1>List of all items</h1><h3 id="structs">Structs</h3><ul class="all-items"><li><a href="struct.Error.html">Error</a></li><li><a href="struct.OsRng.html">OsRng</a></li><li><a href="block/struct.BlockRng.html">block::BlockRng</a></li><li><a href="block/struct.BlockRng64.html">block::BlockRng64</a></li></ul><h3 id="traits">Traits</h3><ul class="all-items"><li><a href="trait.CryptoRng.html">CryptoRng</a></li><li><a href="trait.CryptoRngCore.html">CryptoRngCore</a></li><li><a href="trait.RngCore.html">RngCore</a></li><li><a href="trait.SeedableRng.html">SeedableRng</a></li><li><a href="block/trait.BlockRngCore.html">block::BlockRngCore</a></li></ul><h3 id="functions">Functions</h3><ul class="all-items"><li><a href="impls/fn.fill_bytes_via_next.html">impls::fill_bytes_via_next</a></li><li><a href="impls/fn.fill_via_u32_chunks.html">impls::fill_via_u32_chunks</a></li><li><a href="impls/fn.fill_via_u64_chunks.html">impls::fill_via_u64_chunks</a></li><li><a href="impls/fn.next_u32_via_fill.html">impls::next_u32_via_fill</a></li><li><a href="impls/fn.next_u64_via_fill.html">impls::next_u64_via_fill</a></li><li><a href="impls/fn.next_u64_via_u32.html">impls::next_u64_via_u32</a></li><li><a href="le/fn.read_u32_into.html">le::read_u32_into</a></li><li><a href="le/fn.read_u64_into.html">le::read_u64_into</a></li></ul></section></div></main></body></html>
|
||||
44
rand_core/block/index.html
Normal file
44
rand_core/block/index.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!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="The `BlockRngCore` trait and implementation helpers"><title>rand_core::block - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module block</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a></span><h1>Module <span>block</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/block.rs.html#9-539">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The <code>BlockRngCore</code> trait and implementation helpers</p>
|
||||
<p>The <a href="trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a> trait exists to assist in the implementation of RNGs
|
||||
which generate a block of data in a cache instead of returning generated
|
||||
values directly.</p>
|
||||
<p>Usage of this trait is optional, but provides two advantages:
|
||||
implementations only need to concern themselves with generation of the
|
||||
block, not the various <a href="../trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> methods (especially <a href="../trait.RngCore.html#tymethod.fill_bytes" title="method rand_core::RngCore::fill_bytes"><code>fill_bytes</code></a>, where
|
||||
the optimal implementations are not trivial), and this allows
|
||||
<code>ReseedingRng</code> (see <a href="https://docs.rs/rand"><code>rand</code></a> crate) perform periodic
|
||||
reseeding with very low overhead.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand_core::{RngCore, SeedableRng};
|
||||
<span class="kw">use </span>rand_core::block::{BlockRngCore, BlockRng};
|
||||
|
||||
<span class="kw">struct </span>MyRngCore;
|
||||
|
||||
<span class="kw">impl </span>BlockRngCore <span class="kw">for </span>MyRngCore {
|
||||
<span class="kw">type </span>Item = u32;
|
||||
<span class="kw">type </span>Results = [u32; <span class="number">16</span>];
|
||||
|
||||
<span class="kw">fn </span>generate(<span class="kw-2">&mut </span><span class="self">self</span>, results: <span class="kw-2">&mut </span><span class="self">Self</span>::Results) {
|
||||
<span class="macro">unimplemented!</span>()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>SeedableRng <span class="kw">for </span>MyRngCore {
|
||||
<span class="kw">type </span>Seed = [u8; <span class="number">32</span>];
|
||||
<span class="kw">fn </span>from_seed(seed: <span class="self">Self</span>::Seed) -> <span class="self">Self </span>{
|
||||
<span class="macro">unimplemented!</span>()
|
||||
}
|
||||
}
|
||||
|
||||
<span class="comment">// optionally, also implement CryptoRng for MyRngCore
|
||||
|
||||
// Final RNG.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>rng = BlockRng::<MyRngCore>::seed_from_u64(<span class="number">0</span>);
|
||||
<span class="macro">println!</span>(<span class="string">"First value: {}"</span>, rng.next_u32());</code></pre></div>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.BlockRng.html" title="struct rand_core::block::BlockRng">Block<wbr>Rng</a></div><div class="desc docblock-short">A wrapper type implementing <a href="../trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> for some type implementing
|
||||
<a href="trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a> with <code>u32</code> array buffer; i.e. this can be used to implement
|
||||
a full RNG from just a <code>generate</code> function.</div></li><li><div class="item-name"><a class="struct" href="struct.BlockRng64.html" title="struct rand_core::block::BlockRng64">Block<wbr>Rng64</a></div><div class="desc docblock-short">A wrapper type implementing <a href="../trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> for some type implementing
|
||||
<a href="trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a> with <code>u64</code> array buffer; i.e. this can be used to implement
|
||||
a full RNG from just a <code>generate</code> function.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">Block<wbr>RngCore</a></div><div class="desc docblock-short">A trait for RNGs which do not generate random numbers individually, but in
|
||||
blocks (typically <code>[u32; N]</code>). This technique is commonly used by
|
||||
cryptographic RNGs to improve performance.</div></li></ul></section></div></main></body></html>
|
||||
1
rand_core/block/sidebar-items.js
Normal file
1
rand_core/block/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["BlockRng","BlockRng64"],"trait":["BlockRngCore"]};
|
||||
68
rand_core/block/struct.BlockRng.html
Normal file
68
rand_core/block/struct.BlockRng.html
Normal file
File diff suppressed because one or more lines are too long
56
rand_core/block/struct.BlockRng64.html
Normal file
56
rand_core/block/struct.BlockRng64.html
Normal file
File diff suppressed because one or more lines are too long
15
rand_core/block/trait.BlockRngCore.html
Normal file
15
rand_core/block/trait.BlockRngCore.html
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<!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="A trait for RNGs which do not generate random numbers individually, but in blocks (typically `[u32; N]`). This technique is commonly used by cryptographic RNGs to improve performance."><title>BlockRngCore in rand_core::block - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Block<wbr>RngCore</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Item" title="Item">Item</a></li><li><a href="#associatedtype.Results" title="Results">Results</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.generate" title="generate">generate</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>block</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">block</a></span><h1>Trait <span class="trait">BlockRngCore</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/block.rs.html#68-78">Source</a> </span></div><pre class="rust item-decl"><code>pub trait BlockRngCore {
|
||||
type <a href="#associatedtype.Item" class="associatedtype">Item</a>;
|
||||
type <a href="#associatedtype.Results" class="associatedtype">Results</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><[Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Item" title="type rand_core::block::BlockRngCore::Item">Item</a>]> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><[Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Item" title="type rand_core::block::BlockRngCore::Item">Item</a>]> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a>;
|
||||
|
||||
// Required method
|
||||
fn <a href="#tymethod.generate" class="fn">generate</a>(&mut self, results: &mut Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Results" title="type rand_core::block::BlockRngCore::Results">Results</a>);
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A trait for RNGs which do not generate random numbers individually, but in
|
||||
blocks (typically <code>[u32; N]</code>). This technique is commonly used by
|
||||
cryptographic RNGs to improve performance.</p>
|
||||
<p>See the <a href="index.html" title="mod rand_core::block">module</a> documentation for details.</p>
|
||||
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Item" class="method"><a class="src rightside" href="../../src/rand_core/block.rs.html#70">Source</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a></h4></section></summary><div class="docblock"><p>Results element type, e.g. <code>u32</code>.</p>
|
||||
</div></details><details class="toggle" open><summary><section id="associatedtype.Results" class="method"><a class="src rightside" href="../../src/rand_core/block.rs.html#74">Source</a><h4 class="code-header">type <a href="#associatedtype.Results" class="associatedtype">Results</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><[Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Item" title="type rand_core::block::BlockRngCore::Item">Item</a>]> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><[Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Item" title="type rand_core::block::BlockRngCore::Item">Item</a>]> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a></h4></section></summary><div class="docblock"><p>Results type. This is the ‘block’ an RNG implementing <code>BlockRngCore</code>
|
||||
generates, which will usually be an array like <code>[u32; 16]</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.generate" class="method"><a class="src rightside" href="../../src/rand_core/block.rs.html#77">Source</a><h4 class="code-header">fn <a href="#tymethod.generate" class="fn">generate</a>(&mut self, results: &mut Self::<a class="associatedtype" href="trait.BlockRngCore.html#associatedtype.Results" title="type rand_core::block::BlockRngCore::Results">Results</a>)</h4></section></summary><div class="docblock"><p>Generate a new block of results.</p>
|
||||
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/rand_core/block/trait.BlockRngCore.js" async></script></section></div></main></body></html>
|
||||
11
rand_core/error/struct.Error.html
Normal file
11
rand_core/error/struct.Error.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../rand_core/struct.Error.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../rand_core/struct.Error.html">../../rand_core/struct.Error.html</a>...</p>
|
||||
<script>location.replace("../../rand_core/struct.Error.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
6
rand_core/impls/fn.fill_bytes_via_next.html
Normal file
6
rand_core/impls/fn.fill_bytes_via_next.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Implement `fill_bytes` via `next_u64` and `next_u32`, little-endian order."><title>fill_bytes_via_next in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">fill_bytes_via_next</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#37-53">Source</a> </span></div><pre class="rust item-decl"><code>pub fn fill_bytes_via_next<R: <a class="trait" href="../trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut R</a>, dest: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>])</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>fill_bytes</code> via <code>next_u64</code> and <code>next_u32</code>, little-endian order.</p>
|
||||
<p>The fastest way to fill a slice is usually to work as long as possible with
|
||||
integers. That is why this method mostly uses <code>next_u64</code>, and only when
|
||||
there are 4 or less bytes remaining at the end of the slice it uses
|
||||
<code>next_u32</code> once.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
26
rand_core/impls/fn.fill_via_u32_chunks.html
Normal file
26
rand_core/impls/fn.fill_via_u32_chunks.html
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<!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="Implement `fill_bytes` by reading chunks from the output buffer of a block based RNG."><title>fill_via_u32_chunks in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">fill_<wbr>via_<wbr>u32_<wbr>chunks</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">fill_via_u32_chunks</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#140-142">Source</a> </span></div><pre class="rust item-decl"><code>pub fn fill_via_u32_chunks(src: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u32.html">u32</a>], dest: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]) -> (<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>fill_bytes</code> by reading chunks from the output buffer of a block
|
||||
based RNG.</p>
|
||||
<p>The return values are <code>(consumed_u32, filled_u8)</code>.</p>
|
||||
<p><code>filled_u8</code> is the number of filled bytes in <code>dest</code>, which may be less than
|
||||
the length of <code>dest</code>.
|
||||
<code>consumed_u32</code> is the number of words consumed from <code>src</code>, which is the same
|
||||
as <code>filled_u8 / 4</code> rounded up.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<p>(from <code>IsaacRng</code>)</p>
|
||||
|
||||
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>fill_bytes(<span class="kw-2">&mut </span><span class="self">self</span>, dest: <span class="kw-2">&mut </span>[u8]) {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>read_len = <span class="number">0</span>;
|
||||
<span class="kw">while </span>read_len < dest.len() {
|
||||
<span class="kw">if </span><span class="self">self</span>.index >= <span class="self">self</span>.rsl.len() {
|
||||
<span class="self">self</span>.isaac();
|
||||
}
|
||||
|
||||
<span class="kw">let </span>(consumed_u32, filled_u8) =
|
||||
impls::fill_via_u32_chunks(<span class="kw-2">&mut </span><span class="self">self</span>.rsl[<span class="self">self</span>.index..],
|
||||
<span class="kw-2">&mut </span>dest[read_len..]);
|
||||
|
||||
<span class="self">self</span>.index += consumed_u32;
|
||||
read_len += filled_u8;
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
9
rand_core/impls/fn.fill_via_u64_chunks.html
Normal file
9
rand_core/impls/fn.fill_via_u64_chunks.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!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="Implement `fill_bytes` by reading chunks from the output buffer of a block based RNG."><title>fill_via_u64_chunks in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">fill_via_u64_chunks</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#154-156">Source</a> </span></div><pre class="rust item-decl"><code>pub fn fill_via_u64_chunks(src: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a>], dest: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]) -> (<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>, <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a>)</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>fill_bytes</code> by reading chunks from the output buffer of a block
|
||||
based RNG.</p>
|
||||
<p>The return values are <code>(consumed_u64, filled_u8)</code>.
|
||||
<code>filled_u8</code> is the number of filled bytes in <code>dest</code>, which may be less than
|
||||
the length of <code>dest</code>.
|
||||
<code>consumed_u64</code> is the number of words consumed from <code>src</code>, which is the same
|
||||
as <code>filled_u8 / 8</code> rounded up.</p>
|
||||
<p>See <code>fill_via_u32_chunks</code> for an example.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
2
rand_core/impls/fn.next_u32_via_fill.html
Normal file
2
rand_core/impls/fn.next_u32_via_fill.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Implement `next_u32` via `fill_bytes`, little-endian order."><title>next_u32_via_fill in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">next_u32_via_fill</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#159-163">Source</a> </span></div><pre class="rust item-decl"><code>pub fn next_u32_via_fill<R: <a class="trait" href="../trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut R</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u32.html">u32</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>next_u32</code> via <code>fill_bytes</code>, little-endian order.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
2
rand_core/impls/fn.next_u64_via_fill.html
Normal file
2
rand_core/impls/fn.next_u64_via_fill.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Implement `next_u64` via `fill_bytes`, little-endian order."><title>next_u64_via_fill in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">next_u64_via_fill</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#166-170">Source</a> </span></div><pre class="rust item-decl"><code>pub fn next_u64_via_fill<R: <a class="trait" href="../trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut R</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>next_u64</code> via <code>fill_bytes</code>, little-endian order.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
2
rand_core/impls/fn.next_u64_via_u32.html
Normal file
2
rand_core/impls/fn.next_u64_via_u32.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Implement `next_u64` via `next_u32`, little-endian order."><title>next_u64_via_u32 in rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>impls</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">impls</a></span><h1>Function <span class="fn">next_u64_via_u32</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#24-29">Source</a> </span></div><pre class="rust item-decl"><code>pub fn next_u64_via_u32<R: <a class="trait" href="../trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(rng: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut R</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Implement <code>next_u64</code> via <code>next_u32</code>, little-endian order.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
11
rand_core/impls/index.html
Normal file
11
rand_core/impls/index.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!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="Helper functions for implementing `RngCore` functions."><title>rand_core::impls - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module impls</a></h2><h3><a href="#functions">Module Items</a></h3><ul class="block"><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a></span><h1>Module <span>impls</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/impls.rs.html#9-207">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Helper functions for implementing <code>RngCore</code> functions.</p>
|
||||
<p>For cross-platform reproducibility, these functions all use Little Endian:
|
||||
least-significant part first. For example, <code>next_u64_via_u32</code> takes <code>u32</code>
|
||||
values <code>x, y</code>, then outputs <code>(y << 32) | x</code>. To implement <code>next_u32</code>
|
||||
from <code>next_u64</code> in little-endian order, one should use <code>next_u64() as u32</code>.</p>
|
||||
<p>Byte-swapping (like the std <code>to_le</code> functions) is only needed to convert
|
||||
to/from byte sequences, and since its purpose is reproducibility,
|
||||
non-reproducible sources (e.g. <code>OsRng</code>) need not bother with it.</p>
|
||||
</div></details><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.fill_bytes_via_next.html" title="fn rand_core::impls::fill_bytes_via_next">fill_<wbr>bytes_<wbr>via_<wbr>next</a></div><div class="desc docblock-short">Implement <code>fill_bytes</code> via <code>next_u64</code> and <code>next_u32</code>, little-endian order.</div></li><li><div class="item-name"><a class="fn" href="fn.fill_via_u32_chunks.html" title="fn rand_core::impls::fill_via_u32_chunks">fill_<wbr>via_<wbr>u32_<wbr>chunks</a></div><div class="desc docblock-short">Implement <code>fill_bytes</code> by reading chunks from the output buffer of a block
|
||||
based RNG.</div></li><li><div class="item-name"><a class="fn" href="fn.fill_via_u64_chunks.html" title="fn rand_core::impls::fill_via_u64_chunks">fill_<wbr>via_<wbr>u64_<wbr>chunks</a></div><div class="desc docblock-short">Implement <code>fill_bytes</code> by reading chunks from the output buffer of a block
|
||||
based RNG.</div></li><li><div class="item-name"><a class="fn" href="fn.next_u32_via_fill.html" title="fn rand_core::impls::next_u32_via_fill">next_<wbr>u32_<wbr>via_<wbr>fill</a></div><div class="desc docblock-short">Implement <code>next_u32</code> via <code>fill_bytes</code>, little-endian order.</div></li><li><div class="item-name"><a class="fn" href="fn.next_u64_via_fill.html" title="fn rand_core::impls::next_u64_via_fill">next_<wbr>u64_<wbr>via_<wbr>fill</a></div><div class="desc docblock-short">Implement <code>next_u64</code> via <code>fill_bytes</code>, little-endian order.</div></li><li><div class="item-name"><a class="fn" href="fn.next_u64_via_u32.html" title="fn rand_core::impls::next_u64_via_u32">next_<wbr>u64_<wbr>via_<wbr>u32</a></div><div class="desc docblock-short">Implement <code>next_u64</code> via <code>next_u32</code>, little-endian order.</div></li></ul></section></div></main></body></html>
|
||||
1
rand_core/impls/sidebar-items.js
Normal file
1
rand_core/impls/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["fill_bytes_via_next","fill_via_u32_chunks","fill_via_u64_chunks","next_u32_via_fill","next_u64_via_fill","next_u64_via_u32"]};
|
||||
16
rand_core/index.html
Normal file
16
rand_core/index.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!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="Random number generation traits"><title>rand_core - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>rand_core</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/rand_core/lib.rs.html#10-531">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Random number generation traits</p>
|
||||
<p>This crate is mainly of interest to crates publishing implementations of
|
||||
<a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a>. Other users are encouraged to use the <a href="https://docs.rs/rand"><code>rand</code></a> crate instead
|
||||
which re-exports the main traits and error types.</p>
|
||||
<p><a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> is the core trait implemented by algorithmic pseudo-random number
|
||||
generators and external random-number sources.</p>
|
||||
<p><a href="trait.SeedableRng.html" title="trait rand_core::SeedableRng"><code>SeedableRng</code></a> is an extension trait for construction from fixed seeds and
|
||||
other random number generators.</p>
|
||||
<p><a href="struct.Error.html" title="struct rand_core::Error"><code>Error</code></a> is provided for error-handling. It is safe to use in <code>no_std</code>
|
||||
environments.</p>
|
||||
<p>The <a href="impls/index.html" title="mod rand_core::impls"><code>impls</code></a> and <a href="le/index.html" title="mod rand_core::le"><code>le</code></a> sub-modules include a few small functions to assist
|
||||
implementation of <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a>.</p>
|
||||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="block/index.html" title="mod rand_core::block">block</a></div><div class="desc docblock-short">The <code>BlockRngCore</code> trait and implementation helpers</div></li><li><div class="item-name"><a class="mod" href="impls/index.html" title="mod rand_core::impls">impls</a></div><div class="desc docblock-short">Helper functions for implementing <code>RngCore</code> functions.</div></li><li><div class="item-name"><a class="mod" href="le/index.html" title="mod rand_core::le">le</a></div><div class="desc docblock-short">Little-Endian utilities</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Error.html" title="struct rand_core::Error">Error</a></div><div class="desc docblock-short">Error type of random number generators</div></li><li><div class="item-name"><a class="struct" href="struct.OsRng.html" title="struct rand_core::OsRng">OsRng</a></div><div class="desc docblock-short">A random number generator that retrieves randomness from the
|
||||
operating system.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">Crypto<wbr>Rng</a></div><div class="desc docblock-short">A marker trait used to indicate that an <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> or <a href="block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a>
|
||||
implementation is supposed to be cryptographically secure.</div></li><li><div class="item-name"><a class="trait" href="trait.CryptoRngCore.html" title="trait rand_core::CryptoRngCore">Crypto<wbr>RngCore</a></div><div class="desc docblock-short">An extension trait that is automatically implemented for any type
|
||||
implementing <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> and <a href="trait.CryptoRng.html" title="trait rand_core::CryptoRng"><code>CryptoRng</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a></div><div class="desc docblock-short">The core of a random number generator.</div></li><li><div class="item-name"><a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">Seedable<wbr>Rng</a></div><div class="desc docblock-short">A random number generator that can be explicitly seeded.</div></li></ul></section></div></main></body></html>
|
||||
2
rand_core/le/fn.read_u32_into.html
Normal file
2
rand_core/le/fn.read_u32_into.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Reads unsigned 32 bit integers from `src` into `dst`."><title>read_u32_into in rand_core::le - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>le</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">le</a></span><h1>Function <span class="fn">read_u32_into</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/le.rs.html#18-23">Source</a> </span></div><pre class="rust item-decl"><code>pub fn read_u32_into(src: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>], dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u32.html">u32</a>])</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Reads unsigned 32 bit integers from <code>src</code> into <code>dst</code>.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
2
rand_core/le/fn.read_u64_into.html
Normal file
2
rand_core/le/fn.read_u64_into.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<!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="Reads unsigned 64 bit integers from `src` into `dst`."><title>read_u64_into in rand_core::le - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"><h2><a href="index.html">In rand_<wbr>core::<wbr>le</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a>::<wbr><a href="index.html">le</a></span><h1>Function <span class="fn">read_u64_into</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/le.rs.html#27-32">Source</a> </span></div><pre class="rust item-decl"><code>pub fn read_u64_into(src: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>], dst: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a>])</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Reads unsigned 64 bit integers from <code>src</code> into <code>dst</code>.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
4
rand_core/le/index.html
Normal file
4
rand_core/le/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!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="Little-Endian utilities"><title>rand_core::le - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module le</a></h2><h3><a href="#functions">Module Items</a></h3><ul class="block"><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rand_core</a></span><h1>Module <span>le</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rand_core/le.rs.html#9-56">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Little-Endian utilities</p>
|
||||
<p>Little-Endian order has been chosen for internal usage; this makes some
|
||||
useful functions available.</p>
|
||||
</div></details><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.read_u32_into.html" title="fn rand_core::le::read_u32_into">read_<wbr>u32_<wbr>into</a></div><div class="desc docblock-short">Reads unsigned 32 bit integers from <code>src</code> into <code>dst</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.read_u64_into.html" title="fn rand_core::le::read_u64_into">read_<wbr>u64_<wbr>into</a></div><div class="desc docblock-short">Reads unsigned 64 bit integers from <code>src</code> into <code>dst</code>.</div></li></ul></section></div></main></body></html>
|
||||
1
rand_core/le/sidebar-items.js
Normal file
1
rand_core/le/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["read_u32_into","read_u64_into"]};
|
||||
11
rand_core/os/struct.OsRng.html
Normal file
11
rand_core/os/struct.OsRng.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../rand_core/struct.OsRng.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../rand_core/struct.OsRng.html">../../rand_core/struct.OsRng.html</a>...</p>
|
||||
<script>location.replace("../../rand_core/struct.OsRng.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
rand_core/sidebar-items.js
Normal file
1
rand_core/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"mod":["block","impls","le"],"struct":["Error","OsRng"],"trait":["CryptoRng","CryptoRngCore","RngCore","SeedableRng"]};
|
||||
43
rand_core/struct.Error.html
Normal file
43
rand_core/struct.Error.html
Normal file
File diff suppressed because one or more lines are too long
35
rand_core/struct.OsRng.html
Normal file
35
rand_core/struct.OsRng.html
Normal file
File diff suppressed because one or more lines are too long
17
rand_core/trait.CryptoRng.html
Normal file
17
rand_core/trait.CryptoRng.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!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="A marker trait used to indicate that an `RngCore` or `BlockRngCore` implementation is supposed to be cryptographically secure."><title>CryptoRng in rand_core - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Crypto<wbr>Rng</a></h2><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-CryptoRng-for-%26mut+R" title="&'a mut R">&'a mut R</a></li><li><a href="#impl-CryptoRng-for-Box%3CR%3E" title="Box<R>">Box<R></a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">rand_core</a></span><h1>Trait <span class="trait">CryptoRng</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/rand_core/lib.rs.html#209">Source</a> </span></div><pre class="rust item-decl"><code>pub trait CryptoRng { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A marker trait used to indicate that an <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> or <a href="block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore"><code>BlockRngCore</code></a>
|
||||
implementation is supposed to be cryptographically secure.</p>
|
||||
<p><em>Cryptographically secure generators</em>, also known as <em>CSPRNGs</em>, should
|
||||
satisfy an additional properties over other generators: given the first
|
||||
<em>k</em> bits of an algorithm’s output
|
||||
sequence, it should not be possible using polynomial-time algorithms to
|
||||
predict the next bit with probability significantly greater than 50%.</p>
|
||||
<p>Some generators may satisfy an additional property, however this is not
|
||||
required by this trait: if the CSPRNG’s state is revealed, it should not be
|
||||
computationally-feasible to reconstruct output prior to this. Some other
|
||||
generators allow backwards-computation and are considered <em>reversible</em>.</p>
|
||||
<p>Note that this trait is provided for guidance only and cannot guarantee
|
||||
suitability for cryptographic applications. In general it should only be
|
||||
implemented for well-reviewed code implementing well-regarded algorithms.</p>
|
||||
<p>Note also that use of a <code>CryptoRng</code> does not protect against other
|
||||
weaknesses such as seeding from a weak entropy source or leaking state.</p>
|
||||
</div></details><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-CryptoRng-for-%26mut+R" class="impl"><a class="src rightside" href="../src/rand_core/lib.rs.html#481">Source</a><a href="#impl-CryptoRng-for-%26mut+R" class="anchor">§</a><h3 class="code-header">impl<'a, R: <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&'a mut R</a></h3></section><section id="impl-CryptoRng-for-Box%3CR%3E" class="impl"><a class="src rightside" href="../src/rand_core/lib.rs.html#485">Source</a><a href="#impl-CryptoRng-for-Box%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R: <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/boxed/struct.Box.html" title="struct alloc::boxed::Box">Box</a><R></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-CryptoRng-for-OsRng" class="impl"><a class="src rightside" href="../src/rand_core/os.rs.html#50">Source</a><a href="#impl-CryptoRng-for-OsRng" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> for <a class="struct" href="struct.OsRng.html" title="struct rand_core::OsRng">OsRng</a></h3></section><section id="impl-CryptoRng-for-BlockRng%3CR%3E" class="impl"><a class="src rightside" href="../src/rand_core/block.rs.html#431">Source</a><a href="#impl-CryptoRng-for-BlockRng%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R: <a class="trait" href="block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">BlockRngCore</a> + <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a>> <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> for <a class="struct" href="block/struct.BlockRng.html" title="struct rand_core::block::BlockRng">BlockRng</a><R></h3></section></div><script src="../trait.impl/rand_core/trait.CryptoRng.js" data-ignore-extern-crates="alloc" async></script></section></div></main></body></html>
|
||||
18
rand_core/trait.CryptoRngCore.html
Normal file
18
rand_core/trait.CryptoRngCore.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<!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="An extension trait that is automatically implemented for any type implementing `RngCore` and `CryptoRng`."><title>CryptoRngCore in rand_core - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Crypto<wbr>RngCore</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_rngcore" title="as_rngcore">as_rngcore</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">rand_core</a></span><h1>Trait <span class="trait">CryptoRngCore</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/rand_core/lib.rs.html#229-232">Source</a> </span></div><pre class="rust item-decl"><code>pub trait CryptoRngCore: <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> + <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> {
|
||||
// Required method
|
||||
fn <a href="#tymethod.as_rngcore" class="fn">as_rngcore</a>(&mut self) -> &mut dyn <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> <a href="#" class="tooltip" data-notable-ty="&mut dyn RngCore">ⓘ</a>;
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An extension trait that is automatically implemented for any type
|
||||
implementing <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> and <a href="trait.CryptoRng.html" title="trait rand_core::CryptoRng"><code>CryptoRng</code></a>.</p>
|
||||
<p>It may be used as a trait object, and supports upcasting to <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> via
|
||||
the <a href="trait.CryptoRngCore.html#tymethod.as_rngcore" title="method rand_core::CryptoRngCore::as_rngcore"><code>CryptoRngCore::as_rngcore</code></a> method.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand_core::CryptoRngCore;
|
||||
|
||||
<span class="attr">#[allow(unused)]
|
||||
</span><span class="kw">fn </span>make_token(rng: <span class="kw-2">&mut </span><span class="kw">dyn </span>CryptoRngCore) -> [u8; <span class="number">32</span>] {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>buf = [<span class="number">0u8</span>; <span class="number">32</span>];
|
||||
rng.fill_bytes(<span class="kw-2">&mut </span>buf);
|
||||
buf
|
||||
}</code></pre></div>
|
||||
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.as_rngcore" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#231">Source</a><h4 class="code-header">fn <a href="#tymethod.as_rngcore" class="fn">as_rngcore</a>(&mut self) -> &mut dyn <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a> <a href="#" class="tooltip" data-notable-ty="&mut dyn RngCore">ⓘ</a></h4></section></summary><div class="docblock"><p>Upcast to an <a href="trait.RngCore.html" title="trait rand_core::RngCore"><code>RngCore</code></a> trait object.</p>
|
||||
</div></details></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-CryptoRngCore-for-T" class="impl"><a class="src rightside" href="../src/rand_core/lib.rs.html#234-238">Source</a><a href="#impl-CryptoRngCore-for-T" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="trait.CryptoRng.html" title="trait rand_core::CryptoRng">CryptoRng</a> + <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a>> <a class="trait" href="trait.CryptoRngCore.html" title="trait rand_core::CryptoRngCore">CryptoRngCore</a> for T</h3></section></div><script src="../trait.impl/rand_core/trait.CryptoRngCore.js" async></script><script type="text/json" id="notable-traits-data">{"&mut dyn RngCore":"<h3>Notable traits for <code>dyn <a class=\"trait\" href=\"trait.RngCore.html\" title=\"trait rand_core::RngCore\">RngCore</a></code></h3><pre><code><div class=\"where\">impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html\" title=\"trait std::io::Read\">Read</a> for dyn <a class=\"trait\" href=\"trait.RngCore.html\" title=\"trait rand_core::RngCore\">RngCore</a></div>"}</script></section></div></main></body></html>
|
||||
107
rand_core/trait.RngCore.html
Normal file
107
rand_core/trait.RngCore.html
Normal file
File diff suppressed because one or more lines are too long
110
rand_core/trait.SeedableRng.html
Normal file
110
rand_core/trait.SeedableRng.html
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<!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="A random number generator that can be explicitly seeded."><title>SeedableRng in rand_core - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="rand_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="icon" href="https://www.rust-lang.org/favicon.ico"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../rand_core/index.html"><img src="https://www.rust-lang.org/logos/rust-logo-128x128-blk.png" alt="logo"></a><h2><a href="../rand_core/index.html">rand_<wbr>core</a><span class="version">0.6.4</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Seedable<wbr>Rng</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Seed" title="Seed">Seed</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.from_seed" title="from_seed">from_seed</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.from_entropy" title="from_entropy">from_entropy</a></li><li><a href="#method.from_rng" title="from_rng">from_rng</a></li><li><a href="#method.seed_from_u64" title="seed_from_u64">seed_from_u64</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate rand_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">rand_core</a></span><h1>Trait <span class="trait">SeedableRng</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/rand_core/lib.rs.html#246-419">Source</a> </span></div><pre class="rust item-decl"><code>pub trait SeedableRng: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
|
||||
type <a href="#associatedtype.Seed" class="associatedtype">Seed</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]>;
|
||||
|
||||
// Required method
|
||||
fn <a href="#tymethod.from_seed" class="fn">from_seed</a>(seed: Self::<a class="associatedtype" href="trait.SeedableRng.html#associatedtype.Seed" title="type rand_core::SeedableRng::Seed">Seed</a>) -> Self;
|
||||
|
||||
// Provided methods
|
||||
fn <a href="#method.seed_from_u64" class="fn">seed_from_u64</a>(state: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a>) -> Self { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.from_rng" class="fn">from_rng</a><R: <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a>>(rng: R) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, <a class="struct" href="struct.Error.html" title="struct rand_core::Error">Error</a>> { ... }
|
||||
<span class="item-spacer"></span> fn <a href="#method.from_entropy" class="fn">from_entropy</a>() -> Self { ... }
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A random number generator that can be explicitly seeded.</p>
|
||||
<p>This trait encapsulates the low-level functionality common to all
|
||||
pseudo-random number generators (PRNGs, or algorithmic generators).</p>
|
||||
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Seed" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#292">Source</a><h4 class="code-header">type <a href="#associatedtype.Seed" class="associatedtype">Seed</a>: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.AsMut.html" title="trait core::convert::AsMut">AsMut</a><[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]></h4></section></summary><div class="docblock"><p>Seed type, which is restricted to types mutably-dereferenceable as <code>u8</code>
|
||||
arrays (we recommend <code>[u8; N]</code> for some <code>N</code>).</p>
|
||||
<p>It is recommended to seed PRNGs with a seed of at least circa 100 bits,
|
||||
which means an array of <code>[u8; 12]</code> or greater to avoid picking RNGs with
|
||||
partially overlapping periods.</p>
|
||||
<p>For cryptographic RNG’s a seed of 256 bits is recommended, <code>[u8; 32]</code>.</p>
|
||||
<h5 id="implementing-seedablerng-for-rngs-with-large-seeds"><a class="doc-anchor" href="#implementing-seedablerng-for-rngs-with-large-seeds">§</a>Implementing <code>SeedableRng</code> for RNGs with large seeds</h5>
|
||||
<p>Note that the required traits <code>core::default::Default</code> and
|
||||
<code>core::convert::AsMut<u8></code> are not implemented for large arrays
|
||||
<code>[u8; N]</code> with <code>N</code> > 32. To be able to implement the traits required by
|
||||
<code>SeedableRng</code> for RNGs with such large seeds, the newtype pattern can be
|
||||
used:</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rand_core::SeedableRng;
|
||||
|
||||
<span class="kw">const </span>N: usize = <span class="number">64</span>;
|
||||
<span class="kw">pub struct </span>MyRngSeed(<span class="kw">pub </span>[u8; N]);
|
||||
<span class="kw">pub struct </span>MyRng(MyRngSeed);
|
||||
|
||||
<span class="kw">impl </span>Default <span class="kw">for </span>MyRngSeed {
|
||||
<span class="kw">fn </span>default() -> MyRngSeed {
|
||||
MyRngSeed([<span class="number">0</span>; N])
|
||||
}
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>AsMut<[u8]> <span class="kw">for </span>MyRngSeed {
|
||||
<span class="kw">fn </span>as_mut(<span class="kw-2">&mut </span><span class="self">self</span>) -> <span class="kw-2">&mut </span>[u8] {
|
||||
<span class="kw-2">&mut </span><span class="self">self</span>.<span class="number">0
|
||||
</span>}
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>SeedableRng <span class="kw">for </span>MyRng {
|
||||
<span class="kw">type </span>Seed = MyRngSeed;
|
||||
|
||||
<span class="kw">fn </span>from_seed(seed: MyRngSeed) -> MyRng {
|
||||
MyRng(seed)
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></div><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.from_seed" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#319">Source</a><h4 class="code-header">fn <a href="#tymethod.from_seed" class="fn">from_seed</a>(seed: Self::<a class="associatedtype" href="trait.SeedableRng.html#associatedtype.Seed" title="type rand_core::SeedableRng::Seed">Seed</a>) -> Self</h4></section></summary><div class="docblock"><p>Create a new PRNG using the given seed.</p>
|
||||
<p>PRNG implementations are allowed to assume that bits in the seed are
|
||||
well distributed. That means usually that the number of one and zero
|
||||
bits are roughly equal, and values like 0, 1 and (size - 1) are unlikely.
|
||||
Note that many non-cryptographic PRNGs will show poor quality output
|
||||
if this is not adhered to. If you wish to seed from simple numbers, use
|
||||
<code>seed_from_u64</code> instead.</p>
|
||||
<p>All PRNG implementations should be reproducible unless otherwise noted:
|
||||
given a fixed <code>seed</code>, the same sequence of output should be produced
|
||||
on all runs, library versions and architectures (e.g. check endianness).
|
||||
Any “value-breaking” changes to the generator should require bumping at
|
||||
least the minor version and documentation of the change.</p>
|
||||
<p>It is not required that this function yield the same state as a
|
||||
reference implementation of the PRNG given equivalent seed; if necessary
|
||||
another constructor replicating behaviour from a reference
|
||||
implementation can be added.</p>
|
||||
<p>PRNG implementations should make sure <code>from_seed</code> never panics. In the
|
||||
case that some special values (like an all zero seed) are not viable
|
||||
seeds it is preferable to map these to alternative constant value(s),
|
||||
for example <code>0xBAD5EEDu32</code> or <code>0x0DDB1A5E5BAD5EEDu64</code> (“odd biases? bad
|
||||
seed”). This is assuming only a small number of values must be rejected.</p>
|
||||
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.seed_from_u64" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#335-364">Source</a><h4 class="code-header">fn <a href="#method.seed_from_u64" class="fn">seed_from_u64</a>(state: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u64.html">u64</a>) -> Self</h4></section></summary><div class="docblock"><p>Create a new PRNG using a <code>u64</code> seed.</p>
|
||||
<p>This is a convenience-wrapper around <code>from_seed</code> to allow construction
|
||||
of any <code>SeedableRng</code> from a simple <code>u64</code> value. It is designed such that
|
||||
low Hamming Weight numbers like 0 and 1 can be used and should still
|
||||
result in good, independent seeds to the PRNG which is returned.</p>
|
||||
<p>This <strong>is not suitable for cryptography</strong>, as should be clear given that
|
||||
the input size is only 64 bits.</p>
|
||||
<p>Implementations for PRNGs <em>may</em> provide their own implementations of
|
||||
this function, but the default implementation should be good enough for
|
||||
all purposes. <em>Changing</em> the implementation of this function should be
|
||||
considered a value-breaking change.</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_rng" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#390-394">Source</a><h4 class="code-header">fn <a href="#method.from_rng" class="fn">from_rng</a><R: <a class="trait" href="trait.RngCore.html" title="trait rand_core::RngCore">RngCore</a>>(rng: R) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self, <a class="struct" href="struct.Error.html" title="struct rand_core::Error">Error</a>></h4></section></summary><div class="docblock"><p>Create a new PRNG seeded from another <code>Rng</code>.</p>
|
||||
<p>This may be useful when needing to rapidly seed many PRNGs from a master
|
||||
PRNG, and to allow forking of PRNGs. It may be considered deterministic.</p>
|
||||
<p>The master PRNG should be at least as high quality as the child PRNGs.
|
||||
When seeding non-cryptographic child PRNGs, we recommend using a
|
||||
different algorithm for the master PRNG (ideally a CSPRNG) to avoid
|
||||
correlations between the child PRNGs. If this is not possible (e.g.
|
||||
forking using small non-crypto PRNGs) ensure that your PRNG has a good
|
||||
mixing function on the output or consider use of a hash function with
|
||||
<code>from_seed</code>.</p>
|
||||
<p>Note that seeding <code>XorShiftRng</code> from another <code>XorShiftRng</code> provides an
|
||||
extreme example of what can go wrong: the new PRNG will be a clone
|
||||
of the parent.</p>
|
||||
<p>PRNG implementations are allowed to assume that a good RNG is provided
|
||||
for seeding, and that it is cryptographically secure when appropriate.
|
||||
As of <code>rand</code> 0.7 / <code>rand_core</code> 0.5, implementations overriding this
|
||||
method should ensure the implementation satisfies reproducibility
|
||||
(in prior versions this was not required).</p>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_entropy" class="method"><a class="src rightside" href="../src/rand_core/lib.rs.html#412-418">Source</a><h4 class="code-header">fn <a href="#method.from_entropy" class="fn">from_entropy</a>() -> Self</h4></section></summary><div class="docblock"><p>Creates a new instance of the RNG seeded via <a href="https://docs.rs/getrandom"><code>getrandom</code></a>.</p>
|
||||
<p>This method is the recommended way to construct non-deterministic PRNGs
|
||||
since it is convenient and secure.</p>
|
||||
<p>In case the overhead of using <a href="https://docs.rs/getrandom"><code>getrandom</code></a> to seed <em>many</em> PRNGs is an
|
||||
issue, one may prefer to seed from a local PRNG, e.g.
|
||||
<code>from_rng(thread_rng()).unwrap()</code>.</p>
|
||||
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
||||
<p>If <a href="https://docs.rs/getrandom"><code>getrandom</code></a> is unable to provide secure entropy this method will panic.</p>
|
||||
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SeedableRng-for-BlockRng64%3CR%3E" class="impl"><a class="src rightside" href="../src/rand_core/block.rs.html#412-429">Source</a><a href="#impl-SeedableRng-for-BlockRng64%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R: <a class="trait" href="block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">BlockRngCore</a> + <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a>> <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a> for <a class="struct" href="block/struct.BlockRng64.html" title="struct rand_core::block::BlockRng64">BlockRng64</a><R></h3></section></summary><div class="impl-items"><section id="associatedtype.Seed-1" class="associatedtype trait-impl"><a class="src rightside" href="../src/rand_core/block.rs.html#413">Source</a><a href="#associatedtype.Seed-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Seed" class="associatedtype">Seed</a> = <R as <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a>>::<a class="associatedtype" href="trait.SeedableRng.html#associatedtype.Seed" title="type rand_core::SeedableRng::Seed">Seed</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-SeedableRng-for-BlockRng%3CR%3E" class="impl"><a class="src rightside" href="../src/rand_core/block.rs.html#243-260">Source</a><a href="#impl-SeedableRng-for-BlockRng%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R: <a class="trait" href="block/trait.BlockRngCore.html" title="trait rand_core::block::BlockRngCore">BlockRngCore</a> + <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a>> <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a> for <a class="struct" href="block/struct.BlockRng.html" title="struct rand_core::block::BlockRng">BlockRng</a><R></h3></section></summary><div class="impl-items"><section id="associatedtype.Seed-2" class="associatedtype trait-impl"><a class="src rightside" href="../src/rand_core/block.rs.html#244">Source</a><a href="#associatedtype.Seed-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Seed" class="associatedtype">Seed</a> = <R as <a class="trait" href="trait.SeedableRng.html" title="trait rand_core::SeedableRng">SeedableRng</a>>::<a class="associatedtype" href="trait.SeedableRng.html#associatedtype.Seed" title="type rand_core::SeedableRng::Seed">Seed</a></h4></section></div></details></div><script src="../trait.impl/rand_core/trait.SeedableRng.js" async></script></section></div></main></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue