unique_folder_name

Function unique_folder_name 

Source
pub fn unique_folder_name() -> Result<String, SystemTimeError>
Expand description

Generates a unique folder name using the current system time, process ID, thread ID, and an internal thread-local counter.

This function constructs the folder name by combining :

  • The current system time in nanoseconds since the UNIX epoch,
  • The current process ID,
  • A checksum of the current thread’s ID,
  • An internal thread-local counter which increments on each call within the same thread.

The format of the generated name is “{timestamp}{pid}{tid}_{counter}”, where each component adds a layer of uniqueness, making the name suitable for temporary or unique directory creation in multi-threaded and multi-process environments.

§Returns

A Result< String, SystemTimeError > where :

  • Ok( String ) contains the unique folder name if the current system time can be determined relative to the UNIX epoch,
  • Err( SystemTimeError ) if there is an error determining the system time.

§Examples

use pth ::path ::unique_folder_name;
let folder_name = unique_folder_name().unwrap();
println!( "Generated folder name: {}", folder_name );

§Errors

qqq: doc