1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::ffi::OsString;
use crate::{PathPrefix, PathType, PavedPath};
impl PavedPath {
/// Returns a reference to the contained file, if present
pub fn get_file(&self) -> Option<&OsString> {
self.file.as_ref()
}
/// Returns [true] if the file is [`Option::Some`], and [false] if the file is [`Option::None`]
pub fn has_file(&self) -> bool {
self.file.is_some()
}
/// Returns a reference to the contained [`Vec<OsString>`] containing a list of directories
pub fn get_dirs(&self) -> &Vec<OsString> {
&self.directories
}
/// Returns a reference to the contained [`PathType`]
pub fn get_type(&self) -> PathType {
self.path_type
}
/// Returns if the path is absolute, [true] if it is, [false] if it isn't
pub fn is_absolute(&self) -> bool {
self.path_type == PathType::Absolute
}
/// Returns if the path is relative, [true] if it is, [false] if it isn't
pub fn is_relative(&self) -> bool {
self.path_type == PathType::Relative
}
/// Returns a reference to the contained [`PathPrefix`] if one exists
pub fn get_prefix(&self) -> Option<&PathPrefix> {
self.path_prefix.as_ref()
}
/// Returns the last directory if present, does not return the file if one is set
pub fn last(&self) -> Option<&OsString> {
self.directories.last()
}
}