reifydb_testing/tempdir/
mod.rs

1// Copyright (c) reifydb.com 2025
2// This file is licensed under the AGPL-3.0-or-later, see license.md file
3
4use std::{env, fs, path::Path};
5
6use uuid::Uuid;
7
8pub fn temp_dir<F>(f: F) -> std::io::Result<()>
9where
10	F: FnOnce(&Path) -> std::io::Result<()>,
11{
12	let mut path = env::temp_dir();
13	path.push(format!("reifydb-{}", Uuid::new_v4().to_string()));
14
15	fs::create_dir(&path)?;
16	let result = f(&path);
17
18	let _ = fs::remove_dir_all(&path);
19	result
20}