2025-03-30 22:59:29 +00:00
|
|
|
#![type_length_limit = "32768"] //TODO: reduce me
|
|
|
|
|
|
2024-05-30 22:38:39 +00:00
|
|
|
mod layers;
|
|
|
|
|
mod request;
|
|
|
|
|
mod router;
|
|
|
|
|
mod run;
|
|
|
|
|
mod serve;
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2024-12-14 21:58:01 -05:00
|
|
|
extern crate conduwuit_core as conduwuit;
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2026-01-20 21:01:21 +00:00
|
|
|
conduwuit_macros::introspect_crate! {}
|
|
|
|
|
|
2024-09-26 04:59:16 +00:00
|
|
|
use std::{panic::AssertUnwindSafe, pin::Pin, sync::Arc};
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2024-12-14 21:58:01 -05:00
|
|
|
use conduwuit::{Error, Result, Server};
|
|
|
|
|
use conduwuit_service::Services;
|
2024-09-26 04:59:16 +00:00
|
|
|
use futures::{Future, FutureExt, TryFutureExt};
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2026-11-21 17:59:19 +00:00
|
|
|
pub fn start(
|
2024-12-15 00:05:47 -05:00
|
|
|
server: &Arc<Server>,
|
|
|
|
|
) -> Pin<Box<dyn Future<Output = Result<Arc<Services>>> + Send>> {
|
2024-09-26 04:59:16 +00:00
|
|
|
AssertUnwindSafe(run::start(server.clone()))
|
|
|
|
|
.catch_unwind()
|
|
|
|
|
.map_err(Error::from_panic)
|
|
|
|
|
.unwrap_or_else(Err)
|
|
|
|
|
.boxed()
|
2024-04-29 17:41:15 -07:00
|
|
|
}
|
|
|
|
|
|
2026-11-21 17:59:19 +00:00
|
|
|
pub fn stop(services: Arc<Services>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
|
2024-09-26 04:59:16 +00:00
|
|
|
AssertUnwindSafe(run::stop(services))
|
|
|
|
|
.catch_unwind()
|
|
|
|
|
.map_err(Error::from_panic)
|
|
|
|
|
.unwrap_or_else(Err)
|
|
|
|
|
.boxed()
|
2024-04-29 17:41:15 -07:00
|
|
|
}
|
|
|
|
|
|
2026-11-21 17:59:19 +00:00
|
|
|
pub fn run(services: &Arc<Services>) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> {
|
2024-09-26 04:59:16 +00:00
|
|
|
AssertUnwindSafe(run::run(services.clone()))
|
|
|
|
|
.catch_unwind()
|
|
|
|
|
.map_err(Error::from_panic)
|
|
|
|
|
.unwrap_or_else(Err)
|
|
|
|
|
.boxed()
|
2024-04-29 17:41:15 -07:00
|
|
|
}
|