rustolio-db 0.1.0

An DB extention for the rustolio HTTP-Server
Documentation
//
// SPDX-License-Identifier: MPL-2.0
//
// Copyright (c) 2026 Tobias Binnewies. All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//

use std::{env, fs, path::PathBuf};

pub fn generate_dir(name: &'static str) -> (PathBuf, PathGuard) {
    let path = env::var("CARGO_MANIFEST_DIR").unwrap() + "/" + name;
    let path: PathBuf = path.into();
    fs::create_dir_all(&path).unwrap();
    (path.clone(), PathGuard { path })
}

pub struct PathGuard {
    path: PathBuf,
}

impl Drop for PathGuard {
    fn drop(&mut self) {
        fs::remove_dir_all(&self.path).unwrap();
    }
}