starbase 0.12.0

Framework for building performant command line applications and developer tools.
use std::fmt::{Debug, Display};

/// Generic result for session operations.
pub type AppResult<E> = Result<Option<u8>, E>;

/// A session that is passed to each application run.
#[async_trait::async_trait]
pub trait AppSession: Clone + Send + Sync {
    type Error: Debug + Display + Send + 'static;

    /// Run operations at the start of the application process to setup
    /// the initial state of the session.
    async fn startup(&mut self) -> AppResult<Self::Error> {
        Ok(None)
    }

    /// Run operations after the session state has been created,
    /// but before the main execution.
    async fn analyze(&mut self) -> AppResult<Self::Error> {
        Ok(None)
    }

    /// Run operations in the background of the main execution. The main
    /// execution is defined in [`App::run`](crate::App#method.run), _not_ here.
    async fn execute(&mut self) -> AppResult<Self::Error> {
        Ok(None)
    }

    /// Run operations on success or failure of the other phases.
    async fn shutdown(&mut self) -> AppResult<Self::Error> {
        Ok(None)
    }
}