continuwuity/src/router/mod.rs
strawberry 77e0b76408
apply new rustfmt.toml changes, fix some clippy lints
Signed-off-by: strawberry <strawberry@puppygock.gay>
2024-12-15 01:00:41 -05:00

50 lines
1.1 KiB
Rust

mod layers;
mod request;
mod router;
mod run;
mod serve;
extern crate conduwuit_core as conduwuit;
use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
use conduwuit::{Error, Result, Server};
use conduwuit_service::Services;
use futures::{Future, FutureExt, TryFutureExt};
conduwuit::mod_ctor! {}
conduwuit::mod_dtor! {}
conduwuit::rustc_flags_capture! {}
#[unsafe(no_mangle)]
pub extern "Rust" fn start(
server: &Arc<Server>,
) -> Pin<Box<dyn Future<Output = Result<Arc<Services>>> + Send>> {
AssertUnwindSafe(run::start(server.clone()))
.catch_unwind()
.map_err(Error::from_panic)
.unwrap_or_else(Err)
.boxed()
}
#[unsafe(no_mangle)]
pub extern "Rust" fn stop(
services: Arc<Services>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
AssertUnwindSafe(run::stop(services))
.catch_unwind()
.map_err(Error::from_panic)
.unwrap_or_else(Err)
.boxed()
}
#[unsafe(no_mangle)]
pub extern "Rust" fn run(
services: &Arc<Services>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
AssertUnwindSafe(run::run(services.clone()))
.catch_unwind()
.map_err(Error::from_panic)
.unwrap_or_else(Err)
.boxed()
}