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 FilePath {
38    //! AsRef
39
40    /// Gets the path as a string.
41    pub fn as_str(&self) -> &str {
42        self.path().path()
43    }
44}
45
46impl AsRef<str> for FilePath {
47    fn as_ref(&self) -> &str {
48        self.as_str()
49    }
50}
51
52impl AsRef<std::path::Path> for FilePath {
53    fn as_ref(&self) -> &std::path::Path {
54        self.path().as_ref()
55    }
56}
57
58impl AsRef<OsStr> for FilePath {
59    fn as_ref(&self) -> &OsStr {
60        OsStr::new(self.as_str())
61    }
62}
63
64impl AsRef<FilePath> for FilePath {
65    fn as_ref(&self) -> &FilePath {
66        self
67    }
68}
69
70impl FolderPath {
71    //! AsRef
72
73    /// Gets the path as a string.
74    pub fn as_str(&self) -> &str {
75        self.path().path()
76    }
77}
78
79impl AsRef<str> for FolderPath {
80    fn as_ref(&self) -> &str {
81        self.as_str()
82    }
83}
84
85impl AsRef<std::path::Path> for FolderPath {
86    fn as_ref(&self) -> &std::path::Path {
87        self.path().as_ref()
88    }
89}
90
91impl AsRef<OsStr> for FolderPath {
92    fn as_ref(&self) -> &OsStr {
93        OsStr::new(self.as_str())
94    }
95}
96
97impl AsRef<FolderPath> for FolderPath {
98    fn as_ref(&self) -> &FolderPath {
99        self
100    }
101}