hgame 0.26.4

CG production management structs, e.g. of assets, personnels, progress, etc.
Documentation
use super::*;
use crate::query_msg::QueryMsg;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Notification {
    Qms(Project, QueryMsg),
}

impl Notification {
    pub fn notify(&self) -> AnyResult<()> {
        match self {
            Self::Qms(project, message) => message.notify(project),
        }
    }

    pub fn pop_up(&self) -> bool {
        match self {
            Self::Qms(project, message) => message.pop_up(project),
        }
    }
}

#[async_trait]
pub trait NotifDigest: DynClone + fmt::Debug + Send + Sync {
    fn update_date_range(&mut self);

    async fn notifications(
        &mut self,
        projects: &[Project],
        viewer: &Staff,
    ) -> Result<Vec<Notification>, DatabaseError>;

    async fn mark_instantiated(
        &self,
        notif: &Notification,
        viewer: &Staff,
        target: InstantiationState,
    ) -> Result<(), ModificationError>;

    /// Fetches notifications and then marks them as instantiated immediately.
    async fn notifications_once(
        &mut self,
        projects: &[Project],
        viewer: &Staff,
    ) -> Result<Vec<Notification>, DatabaseError>;
}

dyn_clone::clone_trait_object!(NotifDigest);