Skip to main content

file_storage/path/convert/
to_folder.rs

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