gled 2.28.4

gled is an application for creating animations and effects on artnet or dmx installations
use kanal::{Receiver, Sender, bounded};
use std::sync::OnceLock;
use uuid::Uuid;

static SENDER: OnceLock<Sender<StorageAction>> = OnceLock::new();

pub fn init() -> Receiver<StorageAction> {
    let (tx, rx) = bounded(16);
    SENDER.set(tx).expect("Could not set ACTION_SENDER");
    rx
}

#[derive(Debug)]
pub enum StorageAction {
    /// Nuke the storage folder and restart from scratch
    Nuke,
    /// Restart the storage system
    Restart,
    /// Stop the storage system
    Stop,
    LoadBranches,
    LoadAssets,
    SwitchBranch(String),
    SaveAsset {
        dir_name: &'static str,
        uuid: Uuid,
        json: String,
    },
    DeleteAsset {
        dir_name: &'static str,
        uuid: Uuid,
    },
    Pull,
    Push,
    CountStagedFiles,
    Commit {
        message: String,
    },
}

impl StorageAction {
    pub fn enqueue(self) {
        SENDER
            .get()
            .expect("Could not get ACTION_SENDER")
            .send(self)
            .expect("Could not send action");
    }
}