1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::path::{Display, Path, PathBuf};
use crate::{PavedPath, PlatformStyle};
impl PavedPath {
/// Returns a reference to a [`Path`] representation of the [`PavedPath`]
pub fn as_path(&self) -> &Path {
&self.inner
}
/// Returns a reference to a [`PathBuf`] representation of the [`PavedPath`]
pub fn as_pathbuf(&self) -> &PathBuf {
&self.inner
}
/// Returns the inner [`PathBuf`], consuming self
pub fn to_pathbuf(self) -> PathBuf {
self.inner
}
/// Build the path in the specified [`PlatformStyle`]
///
/// If you want to use it for the platform the binary is running on, [`PavedPath`] also implements [`AsRef<PathBuf>`] allowing you to simply use it as a normal [PathBuf], this [PathBuf] contains the representation native to your platform
pub fn path_in_style(&self, style: PlatformStyle) -> PathBuf {
match style {
PlatformStyle::Unix => self.build_unix_pathbuf(),
PlatformStyle::Windows => self.build_windows_pathbuf(),
}
}
/// Identical to [`std::path::Path::display()`]
///
/// See [`std::path::Path::display()`] for more
pub fn display(&self) -> Display<'_> {
self.inner.display()
}
}