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.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CfgPath
impl<'de> Deserialize<'de> for CfgPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for CfgPath
impl StructuralPartialEq for CfgPath
Auto Trait Implementations§
impl Freeze for CfgPath
impl RefUnwindSafe for CfgPath
impl Send for CfgPath
impl Sync for CfgPath
impl Unpin for CfgPath
impl UnwindSafe for CfgPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes