Skip to main content

file_storage/path/convert/
as_ref.rs

1use crate::{FilePath, FolderPath, StoragePath};
2use std::ffi::OsStr;
3
4impl StoragePath {
5    //! AsRef
6
7    /// Gets the path as a string.
8    pub fn as_str(&self) -> &str {
9        self.path()
10    }
11}
12
13impl AsRef<str> for StoragePath {
14    fn as_ref(&self) -> &str {
15        self.as_str()
16    }
17}
18
19impl AsRef<std::path::Path> for StoragePath {
20    fn as_ref(&self) -> &std::path::Path {
21        self.path().as_ref()
22    }
23}
24
25impl AsRef<OsStr> for StoragePath {
26    fn as_ref(&self) -> &OsStr {
27        OsStr::new(self.as_str())
28    }
29}
30
31impl AsRef<StoragePath> for StoragePath {
32    fn as_ref(&self) -> &StoragePath {
33        self
34    }
35}
36
37impl AsRef<str> for FilePath {
38    fn as_ref(&self) -> &str {
39        self.as_str()
40    }
41}
42
43impl AsRef<std::path::Path> for FilePath {
44    fn as_ref(&self) -> &std::path::Path {
45        self.path().as_ref()
46    }
47}
48
49impl AsRef<OsStr> for FilePath {
50    fn as_ref(&self) -> &OsStr {
51        OsStr::new(self.as_str())
52    }
53}
54
55impl AsRef<FilePath> for FilePath {
56    fn as_ref(&self) -> &FilePath {
57        self
58    }
59}
60
61impl AsRef<str> for FolderPath {
62    fn as_ref(&self) -> &str {
63        self.as_str()
64    }
65}
66
67impl AsRef<std::path::Path> for FolderPath {
68    fn as_ref(&self) -> &std::path::Path {
69        self.path().as_ref()
70    }
71}
72
73impl AsRef<OsStr> for FolderPath {
74    fn as_ref(&self) -> &OsStr {
75        OsStr::new(self.as_str())
76    }
77}
78
79impl AsRef<FolderPath> for FolderPath {
80    fn as_ref(&self) -> &FolderPath {
81        self
82    }
83}