.cargo/config.toml
.cargo/config.toml
This file has not been changed.
.gitignore
.gitignore
This file has not been changed.
.tangled/workflows/miri.yml
.tangled/workflows/miri.yml
This file has not been changed.
.tangled/workflows/test.yml
.tangled/workflows/test.yml
This file has not been changed.
+32
-16
Cargo.lock
+32
-16
Cargo.lock
···
847
"nailkov",
848
"nailrng",
849
"pin-project-lite",
850
-
"rand",
851
"tokio",
852
"tracing",
853
"winnow",
···
882
"itertools",
883
"nailrng",
884
"parking_lot",
885
-
"rand",
886
"rand_distr",
887
"rapidhash",
888
"tracing",
···
969
name = "nailrng"
970
version = "0.1.0"
971
dependencies = [
972
-
"getrandom 0.3.4",
973
-
"rand_core",
974
"wyrand",
975
]
976
···
1051
"nailkov",
1052
"nailrng",
1053
"nailspicy",
1054
-
"rand",
1055
]
1056
1057
[[package]]
···
1213
"futures-util",
1214
"opentelemetry",
1215
"percent-encoding",
1216
-
"rand",
1217
"thiserror",
1218
"tokio",
1219
"tokio-stream",
···
1377
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
1378
dependencies = [
1379
"rand_chacha",
1380
-
"rand_core",
1381
]
1382
1383
[[package]]
1384
1385
1386
1387
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
1388
dependencies = [
1389
"ppv-lite86",
1390
-
"rand_core",
1391
]
1392
1393
[[package]]
···
1400
]
1401
1402
[[package]]
1403
name = "rand_distr"
1404
-
version = "0.5.1"
1405
source = "registry+https://github.com/rust-lang/crates.io-index"
1406
-
checksum = "6a8615d50dcf34fa31f7ab52692afec947c4dd0ab803cc87cb3b0b4570ff7463"
1407
dependencies = [
1408
"num-traits",
1409
-
"rand",
1410
]
1411
1412
[[package]]
···
1415
source = "registry+https://github.com/rust-lang/crates.io-index"
1416
checksum = "b5e48930979c155e2f33aa36ab3119b5ee81332beb6482199a8ecd6029b80b59"
1417
dependencies = [
1418
-
"rand",
1419
"rustversion",
1420
]
1421
···
1940
dependencies = [
1941
"getrandom 0.4.1",
1942
"js-sys",
1943
-
"rand",
1944
"wasm-bindgen",
1945
]
1946
···
2282
2283
[[package]]
2284
name = "wyrand"
2285
-
version = "0.3.2"
2286
source = "registry+https://github.com/rust-lang/crates.io-index"
2287
-
checksum = "15e0359b0b8d9cdef235a1fd4a8c5d02e4c9204e9fac861c14c229a8e803d1a6"
2288
dependencies = [
2289
-
"rand_core",
2290
]
2291
2292
[[package]]
···
847
"nailkov",
848
"nailrng",
849
"pin-project-lite",
850
+
"rand 0.10.0",
851
"tokio",
852
"tracing",
853
"winnow",
···
882
"itertools",
883
"nailrng",
884
"parking_lot",
885
+
"rand 0.10.0",
886
"rand_distr",
887
"rapidhash",
888
"tracing",
···
969
name = "nailrng"
970
version = "0.1.0"
971
dependencies = [
972
+
"getrandom 0.4.1",
973
+
"rand_core 0.10.0",
974
"wyrand",
975
]
976
···
1051
"nailkov",
1052
"nailrng",
1053
"nailspicy",
1054
+
"rand 0.10.0",
1055
]
1056
1057
[[package]]
···
1213
"futures-util",
1214
"opentelemetry",
1215
"percent-encoding",
1216
+
"rand 0.9.2",
1217
"thiserror",
1218
"tokio",
1219
"tokio-stream",
···
1377
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
1378
dependencies = [
1379
"rand_chacha",
1380
+
"rand_core 0.9.5",
1381
]
1382
1383
[[package]]
1384
+
name = "rand"
1385
+
version = "0.10.0"
1386
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1387
+
checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
1388
+
dependencies = [
1389
+
"getrandom 0.4.1",
1390
+
"rand_core 0.10.0",
1391
+
]
1392
1393
+
[[package]]
1394
1395
1396
+
1397
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
1398
dependencies = [
1399
"ppv-lite86",
1400
+
"rand_core 0.9.5",
1401
]
1402
1403
[[package]]
···
1410
]
1411
1412
[[package]]
1413
+
name = "rand_core"
1414
+
version = "0.10.0"
1415
+
source = "registry+https://github.com/rust-lang/crates.io-index"
1416
+
checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
1417
+
1418
+
[[package]]
1419
name = "rand_distr"
1420
+
version = "0.6.0"
1421
source = "registry+https://github.com/rust-lang/crates.io-index"
1422
+
checksum = "4d431c2703ccf129de4d45253c03f49ebb22b97d6ad79ee3ecfc7e3f4862c1d8"
1423
dependencies = [
1424
"num-traits",
1425
+
"rand 0.10.0",
1426
]
1427
1428
[[package]]
···
1431
source = "registry+https://github.com/rust-lang/crates.io-index"
1432
checksum = "b5e48930979c155e2f33aa36ab3119b5ee81332beb6482199a8ecd6029b80b59"
1433
dependencies = [
1434
+
"rand 0.9.2",
1435
"rustversion",
1436
]
1437
···
1956
dependencies = [
1957
"getrandom 0.4.1",
1958
"js-sys",
1959
+
"rand 0.9.2",
1960
"wasm-bindgen",
1961
]
1962
···
2298
2299
[[package]]
2300
name = "wyrand"
2301
+
version = "0.4.1"
2302
source = "registry+https://github.com/rust-lang/crates.io-index"
2303
+
checksum = "b5484c3d24f0e2e117d30bce6f8792e193be33e2b6e0b3f8945ccf265c56c6da"
2304
dependencies = [
2305
+
"rand_core 0.10.0",
2306
]
2307
2308
[[package]]
crates/nailrt/src/lib.rs
crates/nailrt/src/lib.rs
This file has not been changed.
+4
-4
Cargo.toml
+4
-4
Cargo.toml
···
24
hyper = { version = "1.6.0", default-features = false, features = ["server"] }
25
color-eyre = { version = "0.6.3", default-features = false }
26
serde = { version = "1.0.219", features = ["derive"] }
27
-
rand_core = "0.9.3"
28
-
rand = { version = "0.9", default-features = false }
29
-
rand_distr = { version = "0.5.1" }
30
-
wyrand = { version = "0.3.2" }
31
hashbrown = { version = "0.15.2", default-features = false, features = [
32
"equivalent",
33
"inline-more",
···
24
hyper = { version = "1.6.0", default-features = false, features = ["server"] }
25
color-eyre = { version = "0.6.3", default-features = false }
26
serde = { version = "1.0.219", features = ["derive"] }
27
+
rand_core = "0.10"
28
+
rand = { version = "0.10", default-features = false }
29
+
rand_distr = { version = "0.6" }
30
+
wyrand = { version = "0.4" }
31
hashbrown = { version = "0.15.2", default-features = false, features = [
32
"equivalent",
33
"inline-more",
+1
-1
crates/nailgen/src/delay.rs
+1
-1
crates/nailgen/src/delay.rs
+5
-5
crates/nailgen/src/html_gen.rs
+5
-5
crates/nailgen/src/html_gen.rs
···
5
use nailconfig::NailConfig;
6
use nailkov::NailKov;
7
use nailrng::FastRng;
8
-
use rand::{Rng, RngCore, distr::Alphanumeric, seq::IndexedRandom};
9
10
/// Provides either the minimum configured size, or a randomised value between
11
/// the minimum and maximum configured sizes if a maximum is available.
12
#[inline]
13
-
fn get_desired_size(config: &NailConfig, rng: &mut impl RngCore) -> usize {
14
match (
15
config.generator.min_paragraph_size,
16
config.generator.max_paragraph_size,
···
26
pub fn text_generator<'a>(
27
chain: &'a NailKov,
28
size: usize,
29
-
rng: &'a mut impl RngCore,
30
) -> impl Iterator<Item = &'a u8> + 'a {
31
chain
32
.generate_tokens(rng)
···
169
fn paragraph<'a>(
170
chain: &'a NailKov,
171
size: usize,
172
-
rng: &'a mut impl RngCore,
173
) -> impl Iterator<Item = &'a u8> + 'a {
174
b"<p>"
175
.iter()
···
181
fn header<'a>(
182
chain: &'a NailKov,
183
size: usize,
184
-
rng: &'a mut impl RngCore,
185
) -> impl Iterator<Item = &'a u8> + 'a {
186
b"\n<h2>"
187
.iter()
···
5
use nailconfig::NailConfig;
6
use nailkov::NailKov;
7
use nailrng::FastRng;
8
+
use rand::{RngExt, Rng, distr::Alphanumeric, seq::IndexedRandom};
9
10
/// Provides either the minimum configured size, or a randomised value between
11
/// the minimum and maximum configured sizes if a maximum is available.
12
#[inline]
13
+
fn get_desired_size(config: &NailConfig, rng: &mut impl Rng) -> usize {
14
match (
15
config.generator.min_paragraph_size,
16
config.generator.max_paragraph_size,
···
26
pub fn text_generator<'a>(
27
chain: &'a NailKov,
28
size: usize,
29
+
rng: &'a mut impl Rng,
30
) -> impl Iterator<Item = &'a u8> + 'a {
31
chain
32
.generate_tokens(rng)
···
169
fn paragraph<'a>(
170
chain: &'a NailKov,
171
size: usize,
172
+
rng: &'a mut impl Rng,
173
) -> impl Iterator<Item = &'a u8> + 'a {
174
b"<p>"
175
.iter()
···
181
fn header<'a>(
182
chain: &'a NailKov,
183
size: usize,
184
+
rng: &'a mut impl Rng,
185
) -> impl Iterator<Item = &'a u8> + 'a {
186
b"\n<h2>"
187
.iter()
+4
-4
crates/nailkov/src/lib.rs
+4
-4
crates/nailkov/src/lib.rs
···
13
use estr::IdentityHasher;
14
use indexmap::IndexMap;
15
use itertools::Itertools;
16
-
use rand::{RngCore, seq::IteratorRandom};
17
use rand_distr::Distribution;
18
19
use distribution::{TokenWeights, TokenWeightsBuilder};
···
29
chain: CachePadded<IndexMap<TokenPair, TokenWeights, TokenHasher>>,
30
}
31
32
-
pub struct NailKovIter<'a, R: RngCore> {
33
rng: &'a mut R,
34
markov: &'a NailKov,
35
prev: TokenPair,
36
}
37
38
-
impl<R: RngCore> Iterator for NailKovIter<'_, R> {
39
type Item = Token;
40
41
#[inline]
···
52
53
impl NailKov {
54
#[inline]
55
-
pub fn generate_tokens<'a, R: RngCore>(&'a self, rng: &'a mut R) -> NailKovIter<'a, R> {
56
NailKovIter {
57
// A markov chain that was successfully built is never empty, so
58
// it will always return with a value, making unwrapping it safe to do.
···
13
use estr::IdentityHasher;
14
use indexmap::IndexMap;
15
use itertools::Itertools;
16
+
use rand::{Rng, seq::IteratorRandom};
17
use rand_distr::Distribution;
18
19
use distribution::{TokenWeights, TokenWeightsBuilder};
···
29
chain: CachePadded<IndexMap<TokenPair, TokenWeights, TokenHasher>>,
30
}
31
32
+
pub struct NailKovIter<'a, R: Rng> {
33
rng: &'a mut R,
34
markov: &'a NailKov,
35
prev: TokenPair,
36
}
37
38
+
impl<R: Rng> Iterator for NailKovIter<'_, R> {
39
type Item = Token;
40
41
#[inline]
···
52
53
impl NailKov {
54
#[inline]
55
+
pub fn generate_tokens<'a, R: Rng>(&'a self, rng: &'a mut R) -> NailKovIter<'a, R> {
56
NailKovIter {
57
// A markov chain that was successfully built is never empty, so
58
// it will always return with a value, making unwrapping it safe to do.
+1
-1
crates/nailrng/Cargo.toml
+1
-1
crates/nailrng/Cargo.toml
+11
-8
crates/nailrng/src/lib.rs
+11
-8
crates/nailrng/src/lib.rs
···
1
//! A very fast, user-space RNG source in the same vein as `rand`'s `ThreadRng`. Not cryptographically secure,
2
//! is meant to be a very fast entropy source.
3
4
use std::cell::UnsafeCell;
5
6
-
use rand_core::RngCore;
7
use wyrand::WyRand;
8
9
thread_local! {
···
34
}
35
}
36
37
-
impl RngCore for FastRng {
38
#[inline(always)]
39
-
fn next_u32(&mut self) -> u32 {
40
-
self.0.next_u32()
41
}
42
43
#[inline(always)]
44
-
fn next_u64(&mut self) -> u64 {
45
-
self.0.next_u64()
46
}
47
48
#[inline(always)]
49
-
fn fill_bytes(&mut self, dst: &mut [u8]) {
50
-
self.0.fill_bytes(dst);
51
}
52
}
···
1
//! A very fast, user-space RNG source in the same vein as `rand`'s `ThreadRng`. Not cryptographically secure,
2
//! is meant to be a very fast entropy source.
3
4
+
use core::convert::Infallible;
5
use std::cell::UnsafeCell;
6
7
+
use rand_core::{Rng, TryRng};
8
use wyrand::WyRand;
9
10
thread_local! {
···
35
}
36
}
37
38
+
impl TryRng for FastRng {
39
+
type Error = Infallible;
40
+
41
#[inline(always)]
42
+
fn try_next_u32(&mut self) -> Result<u32, Self::Error> {
43
+
self.0.try_next_u32()
44
}
45
46
#[inline(always)]
47
+
fn try_next_u64(&mut self) -> Result<u64, Self::Error> {
48
+
self.0.try_next_u64()
49
}
50
51
#[inline(always)]
52
+
fn try_fill_bytes(&mut self, dst: &mut [u8]) -> Result<(), Infallible> {
53
+
self.0.try_fill_bytes(dst)
54
}
55
}
History
4 rounds
0 comments
1 commit
expand
collapse
Use unstable tokio to build LocalRuntime for nailrt
2/2 success
expand
collapse
expand 0 comments
pull request successfully merged
1 commit
expand
collapse
Use unstable tokio to build LocalRuntime for nailrt
2/2 success
expand
collapse
expand 0 comments
1 commit
expand
collapse
Use unstable tokio to build LocalRuntime for nailrt
1/2 failed, 1/2 timeout
expand
collapse
expand 0 comments
1 commit
expand
collapse
Use unstable tokio to build LocalRuntime for nailrt