1use std::ffi::OsString;
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5use thiserror::Error;
6
7#[cfg(test)]
8mod tests;
9
10mod paved_path;
11
12pub use paved_path::PavedPath;
13
14pub const UNIX_PATH_SEPARATOR: char = '/';
16
17pub const WINDOWS_PATH_SEPARATOR: char = '\\';
19
20pub const CURRENT_PATH_SEPARATOR: char = if cfg!(windows) {
22 WINDOWS_PATH_SEPARATOR
23} else {
24 UNIX_PATH_SEPARATOR
25};
26
27#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
29#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord, Default)]
30pub enum PathType {
31 #[default]
33 Absolute,
34
35 Relative,
37}
38
39#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
41#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
42pub enum PathPrefix {
43 Drive(char),
45
46 UNC(OsString, OsString),
48}
49
50#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
52#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
53pub enum PlatformStyle {
54 #[default]
55 Unix,
56 Windows,
57}
58
59#[derive(Error, Debug, Eq, PartialEq, Ord, PartialOrd, Clone, Copy)]
60pub enum PavedAbsolutizeError {
61 #[error("The root path is relative")]
62 RootIsRelative,
63
64 #[error("The path is already absolute")]
65 PathIsAbsolute,
66}