Skip to main content

nidus/
lib.rs

1#![deny(missing_docs)]
2
3//! Public facade crate for the Nidus framework.
4
5pub mod app;
6pub mod prelude;
7pub mod runtime {
8    //! Tokio runtime types used by Nidus application entrypoint macros.
9
10    pub use tokio::runtime::{Builder, Runtime};
11}
12
13pub use nidus_core::*;
14pub use nidus_macros::*;
15
16pub use app::{NidusApplicationBuilder, NidusApplicationExt};
17
18/// Registers an OpenAPI schema and nested schemas into the provided schema registry.
19#[doc(hidden)]
20pub fn register_openapi_schema<T>(
21    schemas: &mut Vec<(String, serde_json::Value)>,
22) -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>>
23where
24    T: utoipa::ToSchema,
25{
26    let mut openapi_schemas: Vec<(
27        String,
28        utoipa::openapi::RefOr<utoipa::openapi::schema::Schema>,
29    )> = vec![(
30        T::name().to_string(),
31        <T as utoipa::PartialSchema>::schema(),
32    )];
33    <T as utoipa::ToSchema>::schemas(&mut openapi_schemas);
34
35    for (name, schema) in openapi_schemas {
36        schemas.push((name, serde_json::to_value(schema)?));
37    }
38    Ok(())
39}
40
41#[cfg(feature = "auth")]
42pub use nidus_auth as auth;
43#[cfg(feature = "config")]
44pub use nidus_config as config;
45#[cfg(feature = "dashboard")]
46pub use nidus_dashboard as dashboard;
47#[cfg(feature = "events")]
48pub use nidus_events as events;
49#[cfg(feature = "http")]
50pub use nidus_http as http;
51#[cfg(feature = "jobs")]
52pub use nidus_jobs as jobs;
53#[cfg(feature = "observability")]
54pub use nidus_observability as observability;
55#[cfg(feature = "openapi")]
56pub use nidus_openapi as openapi;
57#[cfg(feature = "testing")]
58pub use nidus_testing as testing;
59#[cfg(feature = "validation")]
60pub use nidus_validation as validation;