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;
7pub use crate::i18n::{I18nError, I18nFormatter, I18nManager, tr};
8pub use crate::kit::{Kit, Ready, Unbuilt};
9
10#[cfg(feature = "async")]
11pub use crate::core::AsyncAutoBuilder;
12#[cfg(feature = "async")]
13pub use crate::{AsyncKit, AsyncReady, AsyncUnbuilt};
14
15#[cfg(feature = "confers")]
16pub use crate::kit::Configurable;
17
18#[cfg(feature = "confers-macros")]
19pub use crate::kit::ModuleConfig;
20
21#[cfg(all(feature = "lifecycle", feature = "async"))]
22pub use crate::core::AsyncLifecycle;
23#[cfg(feature = "lifecycle")]
24pub use crate::core::Lifecycle;
25
26#[cfg(all(feature = "health", feature = "async"))]
27pub use crate::core::AsyncHealthCheck;
28#[cfg(feature = "health")]
29pub use crate::core::{HealthCheck, HealthStatus};
30
31#[cfg(feature = "observability")]
32pub use crate::core::BuildObserver;
33
34#[cfg(all(feature = "scope", feature = "async"))]
35pub use crate::kit::AsyncScope;
36#[cfg(feature = "scope")]
37pub use crate::kit::Scope;
38
39#[cfg(all(test, feature = "async"))]
40mod tests {
41    //! Verify the async re-exports reachable through `prelude::*` compile
42    //! against the expected concrete types (`async_kit::Ready` / `Unbuilt`), not
43    //! the sync variants. This guards against a regression where lib.rs
44    //! aliases the wrong `Ready`/`Unbuilt` markers.
45    use crate::kit::async_kit::{Ready as AsyncReadyMarker, Unbuilt as AsyncUnbuiltMarker};
46    use crate::prelude::*;
47
48    #[test]
49    fn prelude_async_kit_compiles() {
50        let _ = AsyncKit::new();
51    }
52
53    #[test]
54    fn prelude_async_markers_match_async_kit_markers() {
55        fn assert_same_type<T: 'static, U: 'static>() {
56            assert_eq!(
57                std::any::TypeId::of::<T>(),
58                std::any::TypeId::of::<U>(),
59                "prelude marker diverged from async_kit marker"
60            );
61        }
62        assert_same_type::<AsyncReady, AsyncReadyMarker>();
63        assert_same_type::<AsyncUnbuilt, AsyncUnbuiltMarker>();
64    }
65
66    #[allow(dead_code, reason = "trait presence check only")]
67    fn _async_auto_builder_is_in_prelude<M: AsyncAutoBuilder>() {}
68}