File
Blob: src/rust/cxx-integration/lib.rs
| 1 | pub mod tokio; |
| 2 | |
| 3 | #[cxx::bridge(namespace = "workerd::rust::cxx_integration")] |
| 4 | mod ffi { |
| 5 | extern "Rust" { |
| 6 | fn init(); |
| 7 | |
| 8 | fn trigger_panic(msg: &str); |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | pub 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. |
| 18 | pub fn init_tokio(worker_threads: Option<usize>) { |
| 19 | tokio::init(worker_threads); |
| 20 | } |
| 21 | |
| 22 | fn trigger_panic(msg: &str) { |
| 23 | panic!("{}", msg) |
| 24 | } |