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-05-09 15:59:08 -07:00
|
|
|
extern crate conduit_core as conduit;
|
2024-04-29 17:41:15 -07:00
|
|
|
|
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-09-26 04:59:16 +00:00
|
|
|
use conduit::{Error, Result, Server};
|
2024-07-27 07:17:07 +00:00
|
|
|
use conduit_service::Services;
|
2024-09-26 04:59:16 +00:00
|
|
|
use futures::{Future, FutureExt, TryFutureExt};
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
conduit::mod_ctor! {}
|
|
|
|
conduit::mod_dtor! {}
|
2024-07-24 23:01:00 +00:00
|
|
|
conduit::rustc_flags_capture! {}
|
2024-04-29 17:41:15 -07:00
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
#[no_mangle]
|
2024-07-27 07:17:07 +00:00
|
|
|
pub extern "Rust" fn start(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
|
|
|
}
|
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
#[no_mangle]
|
2024-07-27 07:17:07 +00:00
|
|
|
pub extern "Rust" 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
|
|
|
}
|
|
|
|
|
2024-05-09 15:59:08 -07:00
|
|
|
#[no_mangle]
|
2024-07-27 07:17:07 +00:00
|
|
|
pub extern "Rust" 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
|
|
|
}
|