file_storage/path/convert/
as_ref.rs1use std::ffi::OsStr;
2
3use crate::{FilePath, FolderPath, StoragePath};
4
5impl StoragePath {
6 pub fn as_str(&self) -> &str {
10 self.path()
11 }
12}
13
14impl AsRef<str> for StoragePath {
15 fn as_ref(&self) -> &str {
16 self.as_str()
17 }
18}
19
20impl AsRef<std::path::Path> for StoragePath {
21 fn as_ref(&self) -> &std::path::Path {
22 self.path().as_ref()
23 }
24}
25
26impl AsRef<OsStr> for StoragePath {
27 fn as_ref(&self) -> &OsStr {
28 OsStr::new(self.as_str())
29 }
30}
31
32impl AsRef<StoragePath> for StoragePath {
33 fn as_ref(&self) -> &StoragePath {
34 self
35 }
36}
37
38impl FilePath {
39 pub fn as_str(&self) -> &str {
43 self.path().path()
44 }
45}
46
47impl AsRef<str> for FilePath {
48 fn as_ref(&self) -> &str {
49 self.as_str()
50 }
51}
52
53impl AsRef<std::path::Path> for FilePath {
54 fn as_ref(&self) -> &std::path::Path {
55 self.path().as_ref()
56 }
57}
58
59impl AsRef<OsStr> for FilePath {
60 fn as_ref(&self) -> &OsStr {
61 OsStr::new(self.as_str())
62 }
63}
64
65impl AsRef<FilePath> for FilePath {
66 fn as_ref(&self) -> &FilePath {
67 self
68 }
69}
70
71impl FolderPath {
72 pub fn as_str(&self) -> &str {
76 self.path().path()
77 }
78}
79
80impl AsRef<str> for FolderPath {
81 fn as_ref(&self) -> &str {
82 self.as_str()
83 }
84}
85
86impl AsRef<std::path::Path> for FolderPath {
87 fn as_ref(&self) -> &std::path::Path {
88 self.path().as_ref()
89 }
90}
91
92impl AsRef<OsStr> for FolderPath {
93 fn as_ref(&self) -> &OsStr {
94 OsStr::new(self.as_str())
95 }
96}
97
98impl AsRef<FolderPath> for FolderPath {
99 fn as_ref(&self) -> &FolderPath {
100 self
101 }
102}