pub struct AppContextBuilder { /* private fields */ }Expand description
the context to store all beans.
AppContext owns the ownership of all registered beans.
When AppContext is dropped, all beans will be dropped too
Implementations§
Source§impl AppContextBuilder
impl AppContextBuilder
Sourcepub fn acquire_bean_or_init<T>(
&self,
_ty: BeanType<T>,
name: &'static str,
) -> BeanRef<T>
pub fn acquire_bean_or_init<T>( &self, _ty: BeanType<T>, name: &'static str, ) -> BeanRef<T>
acquire the BeanRef of a bean.
because of the initialization order, returned BeanRef may not be initialized.
the method acquire_bean_or_init only requires immutable reference, so
the beans which implements BuildFromContext can invoke it during the construction
Sourcepub fn construct_bean<T, E, Err, Err2>(
self,
_ty: BeanType<T>,
name: &'static str,
extras: E,
) -> Result<Self, Err>
pub fn construct_bean<T, E, Err, Err2>( self, _ty: BeanType<T>, name: &'static str, extras: E, ) -> Result<Self, Err>
construct a bean and hand over to AppContextBuilder.
the bean type must implement BuildFromContext
Sourcepub async fn construct_bean_async<T, E, Err, Err2>(
self,
_ty: BeanType<T>,
name: &'static str,
extras: E,
) -> Result<Self, Err>
pub async fn construct_bean_async<T, E, Err, Err2>( self, _ty: BeanType<T>, name: &'static str, extras: E, ) -> Result<Self, Err>
construct a bean and hand over to AppContextBuilder.
the bean type must implement BuildFromContextAsync
Sourcepub fn build_without_init(self) -> Result<AppContext, BeanError>
pub fn build_without_init(self) -> Result<AppContext, BeanError>
finish construction and create AppContext without Mutex.
this method will go over all beans and ensure all beans are initialized,
but the initialization method will not be ran