#![no_std]
#![no_main]

use core::time::Duration;

use libk::{error::Error, log, module::ModuleInfo, task::runtime};

#[no_mangle]
static MODULE: ModuleInfo = ModuleInfo {
    // TODO generate this from manifest toml
    name: "test_mod",
    version: "0.0.1",
    init,
    unload: Some(unload),
};

fn init() -> Result<(), Error> {
    log::info!("Module loaded");
    runtime::spawn(async move {
        loop {
            log::debug!("Tick");
            runtime::sleep(Duration::from_secs(1)).await;
        }
    })
}

fn unload() -> Result<(), Error> {
    log::info!("Module unloaded");
    Ok(())
}
