pub struct CfgPath(/* private fields */);
Expand description
A path in a configuration file: tilde expansion is performed, along
with expansion of variables provided by a CfgPathResolver
.
The tilde expansion is performed using the home directory given by the
directories
crate, which may be based on an environment variable. For more
information, see BaseDirs::home_dir
.
Alternatively, a CfgPath
can contain literal PathBuf
, which will not be expanded.
Implementations§
Source§impl CfgPath
impl CfgPath
Sourcepub fn new_literal<P: Into<PathBuf>>(path: P) -> Self
pub fn new_literal<P: Into<PathBuf>>(path: P) -> Self
Construct a new CfgPath
designating a literal not-to-be-expanded PathBuf
Sourcepub fn path(
&self,
path_resolver: &CfgPathResolver,
) -> Result<PathBuf, CfgPathError>
pub fn path( &self, path_resolver: &CfgPathResolver, ) -> Result<PathBuf, CfgPathError>
Return the path on disk designated by this CfgPath
.
Variables may or may not be resolved using path_resolver
, depending on whether the
expand-paths
feature is enabled or not.
Sourcepub fn as_unexpanded_str(&self) -> Option<&str>
pub fn as_unexpanded_str(&self) -> Option<&str>
If the CfgPath
is a string that should be expanded, return the (unexpanded) string,
Before use, this string would have be to expanded. So if you want a path to actually use,
call path
instead.
Returns None
if the CfgPath
is a literal PathBuf
not intended for expansion.
Sourcepub fn as_literal_path(&self) -> Option<&Path>
pub fn as_literal_path(&self) -> Option<&Path>
If the CfgPath
designates a literal not-to-be-expanded Path
, return a reference to it
Returns None
if the CfgPath
is a string which should be expanded, which is the
usual case.