Application

Trait Application 

Source
pub trait Application:
    Sized
    + Send
    + 'static {
    // Required method
    fn start(&self) -> impl Future<Output = Result<Pid, ExitReason>> + Send;

    // Provided methods
    fn config() -> ApplicationConfig { ... }
    fn run(self) { ... }
    fn test(self) { ... }
}
Expand description

Main application logic and entry point for a hydra program.

Application provides graceful shutdown by allowing you to link a process inside the call to start. The run call will only return once that process has terminated. It’s recommended to link a supervisor.

Required Methods§

Source

fn start(&self) -> impl Future<Output = Result<Pid, ExitReason>> + Send

Called when an application is starting. You should link a process here and return it’s Pid.

The Application will wait for that process to exit before returning from run.

Provided Methods§

Source

fn config() -> ApplicationConfig

Override to change the application configuration defaults.

Source

fn run(self)

Runs the Application to completion.

This method will return when the linked process created in start has exited.

Examples found in repository?
examples/registry.rs (line 116)
114fn main() {
115    // This method will only return once the supervisor linked in `start` has terminated.
116    Application::run(MyApplication)
117}
More examples
Hide additional examples
examples/supervisor.rs (line 122)
120fn main() {
121    // This method will only return once the supervisor linked in `start` has terminated.
122    Application::run(MyApplication)
123}
examples/application.rs (line 90)
88fn main() {
89    // This method will return once the linked Process in StackApplication::start has terminated.
90    Application::run(StackApplication)
91}
Source

fn test(self)

Runs the Application to completion for tests.

This method will panic if the process doesn’t cleanly exit with normal or shutdown reasons.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§