Skip to content
File

Blob: src/rust/cxx-integration/lib.rs

rust25 lines
1pub mod tokio;
2 
3#[cxx::bridge(namespace = "workerd::rust::cxx_integration")]
4mod ffi {
5 extern "Rust" {
6 fn init();
7 
8 fn trigger_panic(msg: &str);
9 }
10}
11 
12pub fn init() {
13 init_tokio(None);
14}
15 
16/// Initialize tokio runtime.
17/// Should not be called directly but as a part of a downstream cxx-integration init.
18pub fn init_tokio(worker_threads: Option<usize>) {
19 tokio::init(worker_threads);
20}
21 
22fn trigger_panic(msg: &str) {
23 panic!("{}", msg)
24}