Sha256: 7c57a068c9f34d8d5a0ed6f4e4b5f31ab70af97bfe2193a326a7251c6dd4c281

Contents?: true

Size: 1018 Bytes

Versions: 16

Compression:

Stored size: 1018 Bytes

Contents

use rand_core::SeedableRng;
use rand_pcg::Pcg64Mcg;
use wasi_common::WasiCtx;

mod clocks;

mod noop_scheduler;
use noop_scheduler::NoopScheduler;

pub fn build_wasi_ctx() -> WasiCtx {
    // Using Pcg64Mcg because it balances memory usage, performance, is adequately random, does not have major issues,
    // and has reproducible results across different platforms. SmallRng and StdRng were considered but are documented
    // as deterministic but not reproducible.
    // See https://rust-random.github.io/book/guide-rngs.html#basic-pseudo-random-number-generators-prngs
    // and https://docs.rs/rand_pcg/latest/rand_pcg/struct.Mcg128Xsl64.html for further details.
    const RANDOM_SEED: u64 = 42; // the answer to life, the universe, and everything
    let random = Box::new(Pcg64Mcg::seed_from_u64(RANDOM_SEED));

    let clocks = clocks::new_clocks();

    let scheduler = Box::new(NoopScheduler::new());
    let table = wasi_common::table::Table::new();
    WasiCtx::new(random, clocks, scheduler, table)
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.29/src/lib.rs
wasmtime-28.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.28/src/lib.rs
wasmtime-27.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.27/src/lib.rs
wasmtime-26.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.26/src/lib.rs
wasmtime-25.0.2 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.25/src/lib.rs
wasmtime-25.0.1 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.25/src/lib.rs
wasmtime-25.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.25/src/lib.rs
wasmtime-24.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.24/src/lib.rs
wasmtime-23.0.2 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.23/src/lib.rs
wasmtime-22.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.22/src/lib.rs
wasmtime-21.0.1 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.22/src/lib.rs
wasmtime-20.0.2 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.21/src/lib.rs
wasmtime-20.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.21/src/lib.rs
wasmtime-18.0.3 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.19/src/lib.rs
wasmtime-17.0.1 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.18/src/lib.rs
wasmtime-17.0.0 ./ext/cargo-vendor/deterministic-wasi-ctx-0.1.18/src/lib.rs