Skip to main content

tuwunel_router/
mod.rs

1mod handle;
2mod layers;
3mod request;
4mod router;
5mod run;
6mod serve;
7
8use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
9
10use futures::{Future, FutureExt, TryFutureExt};
11use log as _;
12use tuwunel_core::{Error, Result, Server};
13use tuwunel_service::Services;
14
15tuwunel_core::mod_ctor! {}
16tuwunel_core::mod_dtor! {}
17tuwunel_core::rustc_flags_capture! {}
18
19#[unsafe(no_mangle)]
20pub extern "Rust" fn start(
21	server: &Arc<Server>,
22) -> Pin<Box<dyn Future<Output = Result<Arc<Services>>> + Send>> {
23	AssertUnwindSafe(run::start(server.clone()))
24		.catch_unwind()
25		.map_err(Error::from_panic)
26		.unwrap_or_else(Err)
27		.boxed()
28}
29
30#[unsafe(no_mangle)]
31pub extern "Rust" fn stop(
32	services: Arc<Services>,
33) -> Pin<Box<dyn Future<Output = Result> + Send>> {
34	AssertUnwindSafe(run::stop(services))
35		.catch_unwind()
36		.map_err(Error::from_panic)
37		.unwrap_or_else(Err)
38		.boxed()
39}
40
41#[unsafe(no_mangle)]
42pub extern "Rust" fn run(
43	services: &Arc<Services>,
44) -> Pin<Box<dyn Future<Output = Result> + Send>> {
45	AssertUnwindSafe(run::run(services.clone()))
46		.catch_unwind()
47		.map_err(Error::from_panic)
48		.unwrap_or_else(Err)
49		.boxed()
50}