[−][src]Enum figment::Source
The source for a configuration value.
The Source
of a given value can be determined via that value's
Metadata.source
retrievable via the value's
Tag
(via Value::tag()
or via the magic value Tagged
) and
Figment::get_metadata()
.
Variants (Non-exhaustive)
File(PathBuf)
A file: the path to the file.
Code(&'static Location<'static>)
Some programatic value: the source location.
Custom(String)
A custom source all-together.
Implementations
impl Source
[src]
pub fn file_path(&self) -> Option<&Path>
[src]
Returns the path to the source file if self.kind
is Kind::File
.
Example
use std::path::Path; use figment::Source; let source = Source::from(Path::new("a/b/c.txt")); assert_eq!(source.file_path(), Some(Path::new("a/b/c.txt")));
pub fn code_location(&self) -> Option<&'static Location<'static>>
[src]
Returns the location to the source code if self
is Source::Code
.
Example
use std::panic::Location; use figment::Source; let location = Location::caller(); let source = Source::Code(location); assert_eq!(source.code_location(), Some(location));
pub fn custom(&self) -> Option<&str>
[src]
Returns the custom source location if self
is Source::Custom
.
Example
use figment::Source; let source = Source::Custom("ftp://foo".into()); assert_eq!(source.custom(), Some("ftp://foo"));
Trait Implementations
impl Clone for Source
[src]
impl Debug for Source
[src]
impl Display for Source
[src]
Displays the source. Location and custom sources are displayed directly. File paths are displayed relative to the current working directory if the relative path is shorter than the complete path.
impl<'_> From<&'_ Path> for Source
[src]
impl<'_> From<&'_ str> for Source
[src]
impl From<&'static Location<'static>> for Source
[src]
impl From<String> for Source
[src]
impl PartialEq<Source> for Source
[src]
impl StructuralPartialEq for Source
[src]
Auto Trait Implementations
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,