Skip to main content

trait_kit/
prelude.rs

1// Copyright (c) 2026 Kirky.X
2// SPDX-License-Identifier: MIT
3//! Re-exports of the most commonly used types and traits.
4
5pub use crate::core::{AutoBuilder, ModuleMeta};
6pub use crate::error::TraitKitError;
7#[cfg(feature = "i18n")]
8pub use crate::i18n::I18nFormatter;
9pub use crate::i18n::{I18nError, I18nManager, tr};
10pub use crate::kit::{Kit, Ready, Unbuilt};
11
12#[cfg(feature = "async")]
13pub use crate::core::AsyncAutoBuilder;
14#[cfg(feature = "async")]
15pub use crate::{AsyncKit, AsyncReady, AsyncUnbuilt};
16
17#[cfg(feature = "confers")]
18pub use crate::kit::Configurable;
19
20#[cfg(feature = "confers")]
21pub use crate::kit::ModuleConfig;
22#[cfg(feature = "confers")]
23pub use crate::kit::Validatable;
24
25#[cfg(all(feature = "lifecycle", feature = "async"))]
26pub use crate::core::AsyncLifecycle;
27#[cfg(feature = "lifecycle")]
28pub use crate::core::Lifecycle;
29
30#[cfg(all(feature = "health", feature = "async"))]
31pub use crate::core::AsyncHealthCheck;
32#[cfg(feature = "health")]
33pub use crate::core::{HealthCheck, HealthStatus};
34
35#[cfg(feature = "observer")]
36pub use crate::core::BuildObserver;
37
38#[cfg(all(feature = "scope", feature = "async"))]
39pub use crate::kit::AsyncScope;
40#[cfg(feature = "scope")]
41pub use crate::kit::Scope;
42
43#[cfg(all(feature = "shutdown", feature = "async"))]
44pub use crate::kit::AsyncShutdownCoordinator;
45#[cfg(feature = "shutdown")]
46pub use crate::kit::{ShutdownCoordinator, ShutdownPhase, ShutdownPhaseResult, ShutdownResult};
47
48#[cfg(all(test, feature = "async"))]
49mod tests {
50    //! Verify the async re-exports reachable through `prelude::*` compile
51    //! against the expected concrete types (`async_kit::Ready` / `Unbuilt`), not
52    //! the sync variants. This guards against a regression where lib.rs
53    //! aliases the wrong `Ready`/`Unbuilt` markers.
54    use crate::kit::async_kit::{Ready as AsyncReadyMarker, Unbuilt as AsyncUnbuiltMarker};
55    use crate::prelude::*;
56
57    #[test]
58    fn prelude_async_kit_compiles() {
59        let _ = AsyncKit::new();
60    }
61
62    #[test]
63    fn prelude_async_markers_match_async_kit_markers() {
64        fn assert_same_type<T: 'static, U: 'static>() {
65            assert_eq!(
66                std::any::TypeId::of::<T>(),
67                std::any::TypeId::of::<U>(),
68                "prelude marker diverged from async_kit marker"
69            );
70        }
71        assert_same_type::<AsyncReady, AsyncReadyMarker>();
72        assert_same_type::<AsyncUnbuilt, AsyncUnbuiltMarker>();
73    }
74
75    #[allow(dead_code, reason = "trait presence check only")]
76    fn _async_auto_builder_is_in_prelude<M: AsyncAutoBuilder>() {}
77}