pub struct Json;
Available on crate feature
json
only.Expand description
A JSON Format
Data
provider. See Data
for details.
use figment::providers::{Format, Json};
// Source directly from a source string...
let provider = Json::string("source-string");
// Or read from a file on disk.
let provider = Json::file("path-to-file");
See also serde_json::from_str
for parsing details.
Trait Implementations
sourceimpl Format for Json
impl Format for Json
sourcefn 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
. Read more
sourcefn 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. Read more
Auto Trait Implementations
impl RefUnwindSafe for Json
impl Send for Json
impl Sync for Json
impl Unpin for Json
impl UnwindSafe for Json
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more