file_storage/path/convert/to_file.rs
1use crate::{Error, FilePath, Operation, Reason, StoragePath};
2
3impl StoragePath {
4 //! To File
5
6 /// Converts the path to a file path.
7 ///
8 /// Returns `Err(self)` if the path is not a file path.
9 pub fn to_file(self) -> Result<FilePath, Error> {
10 if self.is_file() {
11 Ok(unsafe { FilePath::new(self) })
12 } else {
13 Err(Error::new(self, Operation::ModifyPath, Reason::Other))
14 }
15 }
16}