proc_lock_api/
lock_path.rs

1use std::path::{Path, PathBuf};
2
3/// Represents the path in which the lock should be created.
4#[derive(Debug)]
5pub enum LockPath<P: AsRef<Path>> {
6    /// Indicates that `P` should be created in `std::env::temp_dir()`
7    Tmp(P),
8    /// Indicates that `P` is an absolute path
9    FullPath(P),
10}
11
12impl<P: AsRef<Path>> LockPath<P> {
13    pub(crate) fn to_path_buf(&self) -> PathBuf {
14        match self {
15            LockPath::Tmp(path) => std::env::temp_dir().join(path),
16            LockPath::FullPath(path) => path.as_ref().to_path_buf(),
17        }
18    }
19}