pub struct HomeConfig { /* private fields */ }Expand description
Use the configuration file in the current user directory
Implementations§
Source§impl HomeConfig
impl HomeConfig
Sourcepub fn with_config_dir<P: AsRef<Path>>(
app_name: &'static str,
file_name: P,
) -> Self
pub fn with_config_dir<P: AsRef<Path>>( app_name: &'static str, file_name: P, ) -> Self
Parse or create configuration file
eg. /home/name/.config/app/config
Sourcepub fn with_file<P: AsRef<Path>>(p: P) -> Self
pub fn with_file<P: AsRef<Path>>(p: P) -> Self
Parse or create configuration file
eg. /home/name/test.json
Sourcepub fn read_to_string(&self) -> IoResult<String>
pub fn read_to_string(&self) -> IoResult<String>
Read the entire contents of a file into a string
Sourcepub fn read_to_vec(&self) -> IoResult<Vec<u8>>
pub fn read_to_vec(&self) -> IoResult<Vec<u8>>
Read the entire contents of a file into a Vec<u8>
Sourcepub fn json<T>(&self) -> Result<T, JsonError>where
T: DeserializeOwned,
pub fn json<T>(&self) -> Result<T, JsonError>where
T: DeserializeOwned,
Parse the config file from json content
Sourcepub fn yaml<T>(&self) -> Result<T, YamlError>where
T: DeserializeOwned,
pub fn yaml<T>(&self) -> Result<T, YamlError>where
T: DeserializeOwned,
Parse the config file from yaml content
Sourcepub fn toml<T>(&self) -> Result<T, TomlParseError>where
T: DeserializeOwned,
pub fn toml<T>(&self) -> Result<T, TomlParseError>where
T: DeserializeOwned,
Parse the config file from toml content
Sourcepub fn hcl<T>(&self) -> Result<T, HclError>where
T: DeserializeOwned,
pub fn hcl<T>(&self) -> Result<T, HclError>where
T: DeserializeOwned,
Parse the config file from hcl content
Sourcepub fn save_json<T>(&self, data: T) -> Result<(), JsonError>where
T: Serialize,
pub fn save_json<T>(&self, data: T) -> Result<(), JsonError>where
T: Serialize,
Save struct to local file (json format)
Sourcepub fn save_yaml<T>(&self, data: T) -> Result<(), YamlError>where
T: Serialize,
pub fn save_yaml<T>(&self, data: T) -> Result<(), YamlError>where
T: Serialize,
Save struct to local file (yaml format)
Sourcepub fn save_toml<T>(&self, data: T) -> Result<(), TomlSaveError>where
T: Serialize,
pub fn save_toml<T>(&self, data: T) -> Result<(), TomlSaveError>where
T: Serialize,
Save struct to local file (toml format)
Trait Implementations§
Source§impl Clone for HomeConfig
impl Clone for HomeConfig
Source§fn clone(&self) -> HomeConfig
fn clone(&self) -> HomeConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for HomeConfig
impl RefUnwindSafe for HomeConfig
impl Send for HomeConfig
impl Sync for HomeConfig
impl Unpin for HomeConfig
impl UnwindSafe for HomeConfig
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