Creates a new [`InputPath`]. # Errors Returns an error if - `base_dir` is not absolute, - `base_dir` is not a directory, - or `path` is not relative.
(base_dir: &'a Path, path: &'b Path)
| 34 | /// - `base_dir` is not a directory, |
| 35 | /// - or `path` is not relative. |
| 36 | pub fn new(base_dir: &'a Path, path: &'b Path) -> Result<Self, crate::Error> { |
| 37 | if !base_dir.is_absolute() { |
| 38 | return Err(crate::Error::NonAbsolutePaths { |
| 39 | paths: vec![base_dir.to_path_buf()], |
| 40 | }); |
| 41 | } |
| 42 | if !base_dir.is_dir() { |
| 43 | return Err(crate::Error::NotADirectory { |
| 44 | path: base_dir.to_path_buf(), |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | if !path.is_relative() { |
| 49 | return Err(crate::Error::NonRelativePaths { |
| 50 | paths: vec![path.to_path_buf()], |
| 51 | }); |
| 52 | } |
| 53 | |
| 54 | Ok(Self { base_dir, path }) |
| 55 | } |
| 56 | |
| 57 | /// Returns a reference to the base dir. |
| 58 | pub fn base_dir(&self) -> &Path { |
nothing calls this directly
no test coverage detected