pub trait Module:
Send
+ Sync
+ 'static {
Show 19 methods
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn imports(&self) -> Vec<Arc<dyn Module>> { ... }
fn forward_imports(&self) -> Vec<Arc<dyn Module>> { ... }
fn providers(&self) -> Result<Vec<ProviderDefinition>> { ... }
fn exports(&self) -> Result<Vec<ProviderToken>> { ... }
fn is_global(&self) -> bool { ... }
fn route_prefix(&self) -> Option<&str> { ... }
fn middleware(&self) -> Vec<Arc<dyn Middleware>> { ... }
fn configure(
&self,
_consumer: &mut MiddlewareConsumer,
_module_ref: &ModuleRef,
) -> Result<()> { ... }
fn controllers(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<ControllerDefinition>> { ... }
fn routes(&self) -> Result<Vec<RouteDefinition>> { ... }
fn gateways(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<WebSocketGatewayDefinition>> { ... }
fn message_patterns(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<MessagePatternDefinition>> { ... }
fn on_module_init(&self, _module_ref: &ModuleRef) -> Result<()> { ... }
fn on_application_bootstrap(
&self,
_module_ref: ModuleRef,
) -> BoxFuture<'static, Result<()>> { ... }
fn on_module_destroy(
&self,
_module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>> { ... }
fn before_application_shutdown(
&self,
_module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>> { ... }
fn on_application_shutdown(
&self,
_module_ref: ModuleRef,
) -> BoxFuture<'static, Result<()>> { ... }
fn on_application_shutdown_with_signal(
&self,
module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>> { ... }
}Expand description
A module contributes imports, providers, controllers, and routes.
This is the Rust equivalent of a Nest module boundary. Modules organize the application graph; HTTP serving remains delegated to an adapter.
Required Methods§
Provided Methods§
Sourcefn imports(&self) -> Vec<Arc<dyn Module>>
fn imports(&self) -> Vec<Arc<dyn Module>>
Imported modules that should be registered before this module.
Sourcefn forward_imports(&self) -> Vec<Arc<dyn Module>>
fn forward_imports(&self) -> Vec<Arc<dyn Module>>
Forward module imports for intentional circular module relationships.
This mirrors the module side of Nest’s forwardRef(...). Forward imports
can reference a module that is currently being registered; exported
providers become visible once the target module finishes registration.
Provider cycles should still use lazy crate::ProviderRef handles.
Sourcefn providers(&self) -> Result<Vec<ProviderDefinition>>
fn providers(&self) -> Result<Vec<ProviderDefinition>>
Providers exported into the application container.
Sourcefn exports(&self) -> Result<Vec<ProviderToken>>
fn exports(&self) -> Result<Vec<ProviderToken>>
Providers this module exposes to importing modules.
Sourcefn is_global(&self) -> bool
fn is_global(&self) -> bool
Whether exported providers should be visible to every module scope.
Sourcefn route_prefix(&self) -> Option<&str>
fn route_prefix(&self) -> Option<&str>
Optional HTTP route prefix applied to controllers and direct routes in this module and its imports.
Sourcefn middleware(&self) -> Vec<Arc<dyn Middleware>>
fn middleware(&self) -> Vec<Arc<dyn Middleware>>
Middleware applied to controllers and direct routes declared by this module.
Sourcefn configure(
&self,
_consumer: &mut MiddlewareConsumer,
_module_ref: &ModuleRef,
) -> Result<()>
fn configure( &self, _consumer: &mut MiddlewareConsumer, _module_ref: &ModuleRef, ) -> Result<()>
Configure route-scoped middleware with a Nest-style consumer.
Sourcefn controllers(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<ControllerDefinition>>
fn controllers( &self, _module_ref: &ModuleRef, ) -> Result<Vec<ControllerDefinition>>
Controller route groups built with access to the provider container.
Sourcefn routes(&self) -> Result<Vec<RouteDefinition>>
fn routes(&self) -> Result<Vec<RouteDefinition>>
Framework-neutral routes contributed directly by this module.
Sourcefn gateways(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<WebSocketGatewayDefinition>>
fn gateways( &self, _module_ref: &ModuleRef, ) -> Result<Vec<WebSocketGatewayDefinition>>
WebSocket gateways contributed by this module.
Sourcefn message_patterns(
&self,
_module_ref: &ModuleRef,
) -> Result<Vec<MessagePatternDefinition>>
fn message_patterns( &self, _module_ref: &ModuleRef, ) -> Result<Vec<MessagePatternDefinition>>
Microservice message patterns contributed by this module.
Sourcefn on_module_init(&self, _module_ref: &ModuleRef) -> Result<()>
fn on_module_init(&self, _module_ref: &ModuleRef) -> Result<()>
Lifecycle hook called after imports and providers are registered.
Sourcefn on_application_bootstrap(
&self,
_module_ref: ModuleRef,
) -> BoxFuture<'static, Result<()>>
fn on_application_bootstrap( &self, _module_ref: ModuleRef, ) -> BoxFuture<'static, Result<()>>
Async lifecycle hook called by hosts that want startup work before serve.
Sourcefn on_module_destroy(
&self,
_module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>>
fn on_module_destroy( &self, _module_ref: ModuleRef, _signal: Option<String>, ) -> BoxFuture<'static, Result<()>>
Async lifecycle hook called when shutdown begins.
Sourcefn before_application_shutdown(
&self,
_module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>>
fn before_application_shutdown( &self, _module_ref: ModuleRef, _signal: Option<String>, ) -> BoxFuture<'static, Result<()>>
Async lifecycle hook called after module destroy hooks and before final shutdown hooks.
Sourcefn on_application_shutdown(
&self,
_module_ref: ModuleRef,
) -> BoxFuture<'static, Result<()>>
fn on_application_shutdown( &self, _module_ref: ModuleRef, ) -> BoxFuture<'static, Result<()>>
Async lifecycle hook called by hosts that need graceful shutdown cleanup.
Sourcefn on_application_shutdown_with_signal(
&self,
module_ref: ModuleRef,
_signal: Option<String>,
) -> BoxFuture<'static, Result<()>>
fn on_application_shutdown_with_signal( &self, module_ref: ModuleRef, _signal: Option<String>, ) -> BoxFuture<'static, Result<()>>
Signal-aware variant of Module::on_application_shutdown.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".