Skip to main content

Toml

Struct Toml 

Source
pub struct Toml;
Available on crate feature toml only.
Expand description

A TOML Format Data provider.

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

Source§

const NAME: &'static str = "TOML"

The name of the data format, for instance "JSON" or "TOML".
Source§

type Error = Error

The data format’s error type.
Source§

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>

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>

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>

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>

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 UnsafeUnpin for Toml

§

impl UnwindSafe for Toml

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.