create_managed_temp_dir

Function create_managed_temp_dir 

Source
pub fn create_managed_temp_dir() -> Result<PathBuf>
Expand description

Create a managed temporary directory with explicit cleanup support

Creates a temporary directory with a timestamped name that can be cleaned up even if the process is killed with SIGKILL. Unlike TempDir::new() which relies on the Drop trait, this function creates named directories that can be cleaned up on next process startup.

Directory naming format: postgres-seren-replicator-{timestamp}-{random} Example: postgres-seren-replicator-20250106-120534-a3b2c1d4

§Returns

Returns the path to the created temporary directory.

§Errors

Returns an error if the directory cannot be created.

§Examples

let temp_path = create_managed_temp_dir()?;
println!("Using temp directory: {}", temp_path.display());
// ... do work ...
// Cleanup happens automatically on next startup via cleanup_stale_temp_dirs()