tauri-plugin-nosleep 2.0.0-beta.1

Tauri plugin to prevent the power save functionality in the OS
use nosleep::NoSleepType;
use tauri::{command, AppHandle, Runtime, State, Window};

use crate::{NoSleepState, Result};

#[command]
pub(crate) async fn block<R: Runtime>(
    _app: AppHandle<R>,
    _window: Window<R>,
    state: State<'_, NoSleepState>,
    no_sleep_type: NoSleepType,
) -> Result<()> {
    state.no_sleep.lock().unwrap().start(no_sleep_type)?;
    Ok(())
}

#[command]
pub(crate) async fn unblock<R: Runtime>(
    _app: AppHandle<R>,
    _window: Window<R>,
    state: State<'_, NoSleepState>,
) -> Result<()> {
    state.no_sleep.lock().unwrap().stop()?;
    Ok(())
}