tlsn_wasm/
lib.rs

1//! TLSNotary WASM bindings.
2
3#![cfg(target_arch = "wasm32")]
4#![deny(unreachable_pub, unused_must_use, clippy::all)]
5#![allow(non_snake_case)]
6
7pub(crate) mod io;
8mod log;
9pub mod prover;
10#[cfg(feature = "test")]
11pub mod tests;
12pub mod types;
13pub mod verifier;
14
15pub use log::{LoggingConfig, LoggingLevel};
16
17use wasm_bindgen::prelude::*;
18use wasm_bindgen_futures::JsFuture;
19
20#[cfg(feature = "test")]
21pub use tests::*;
22
23/// Initializes the module.
24#[wasm_bindgen]
25pub async fn initialize(
26    logging_config: Option<LoggingConfig>,
27    thread_count: usize,
28) -> Result<(), JsValue> {
29    log::init_logging(logging_config);
30
31    JsFuture::from(web_spawn::start_spawner()).await?;
32
33    // Initialize rayon global thread pool.
34    rayon::ThreadPoolBuilder::new()
35        .num_threads(thread_count)
36        .spawn_handler(|thread| {
37            // Drop join handle.
38            let _ = web_spawn::spawn(move || thread.run());
39            Ok(())
40        })
41        .build_global()
42        .unwrap_throw();
43
44    Ok(())
45}