pub struct Toml;Available on crate feature
toml only.Expand description
Static constructor methods on Toml return a
Data value with a generic marker of Toml.
Thus, further use occurs via methods on Data.
use figment::providers::{Format, Toml};
// Source directly from a source string...
let provider = Toml::string("source-string");
// Or read from a file on disk.
let provider = Toml::file("path-to-file");
// Or configured as nested (via Data::nested()):
let provider = Toml::file("path-to-file").nested();See also [toml::from_str] for parsing details.
Trait Implementations§
Source§impl Format for Toml
impl Format for Toml
Source§fn from_str<'de, T: DeserializeOwned>(s: &'de str) -> Result<T, Error>
fn from_str<'de, T: DeserializeOwned>(s: &'de str) -> Result<T, Error>
Parses
string as the data format Self as a T or returns an error
if the string is an invalid T. Note: This method is not
intended to be called directly. Instead, it is intended to be
implemented and then used indirectly via the Data::file() or
Data::string() methods.Source§fn file<P: AsRef<Path>>(path: P) -> Data<Self>
fn file<P: AsRef<Path>>(path: P) -> Data<Self>
Returns a
Data provider that sources its values by parsing the file at
path as format Self. See Data::file() for more details. The
default implementation calls Data::file(path).Source§fn file_exact<P: AsRef<Path>>(path: P) -> Data<Self>
fn file_exact<P: AsRef<Path>>(path: P) -> Data<Self>
Returns a
Data provider that sources its values by parsing the file at
path as format Self. See Data::file_exact() for more details. The
default implementation calls Data::file_exact(path).Source§fn string(string: &str) -> Data<Self>
fn string(string: &str) -> Data<Self>
Returns a
Data provider that sources its values by parsing string as
format Self. See Data::string() for more details. The default
implementation calls Data::string(string).Source§fn from_path<T: DeserializeOwned>(path: &Path) -> Result<T, Self::Error>
fn from_path<T: DeserializeOwned>(path: &Path) -> Result<T, Self::Error>
Parses the file at
path as the data format Self as a T or returns
an error if the string is an invalid T. The default implementation
calls Format::from_str() with the contents of the file. Note:
This method is not intended to be called directly. Instead, it is
intended to be implemented on special occasions and then used
indirectly via the Data::file() or Data::string() methods.Auto Trait Implementations§
impl Freeze for Toml
impl RefUnwindSafe for Toml
impl Send for Toml
impl Sync for Toml
impl Unpin for Toml
impl UnwindSafe for Toml
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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: 0 bytes