pub struct App;Expand description
Application container facade
Provides static methods for service registration and resolution. Uses a global container with thread-local test overrides.
§Example
ⓘ
use kit::App;
// Register services at startup
App::singleton(DatabaseConnection::new(&url));
App::bind::<dyn HttpClient>(Arc::new(RealHttpClient::new()));
// Resolve anywhere
let db: DatabaseConnection = App::get().unwrap();
let client: Arc<dyn HttpClient> = App::make::<dyn HttpClient>().unwrap();Implementations§
Source§impl App
impl App
Sourcepub fn init()
pub fn init()
Initialize the application container
Should be called once at application startup. This is automatically
called by Server::from_config().
Sourcepub fn bind_factory<T: ?Sized + Send + Sync + 'static, F>(factory: F)
pub fn bind_factory<T: ?Sized + Send + Sync + 'static, F>(factory: F)
Sourcepub fn has_binding<T: ?Sized + 'static>() -> bool
pub fn has_binding<T: ?Sized + 'static>() -> bool
Check if a trait binding is registered
Sourcepub fn boot_services()
pub fn boot_services()
Boot all auto-registered services
This registers all services marked with #[service(ConcreteType)].
Called automatically by Server::from_config().
Auto Trait Implementations§
impl Freeze for App
impl RefUnwindSafe for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnwindSafe for App
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more