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 ferro_rs::{App, bind, singleton};
// Register services at startup using macros
singleton!(DatabaseConnection::new(&url));
bind!(dyn HttpClient, 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 resolve_make<T: ?Sized + Send + Sync + 'static>() -> Result<Arc<T>, FrameworkError>
pub fn resolve_make<T: ?Sized + Send + Sync + 'static>() -> Result<Arc<T>, FrameworkError>
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 UnsafeUnpin 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more