Struct config_file_handler::FileHandler
[−]
[src]
pub struct FileHandler<T> { // some fields omitted }
Struct for reading and writing config files.
Thread- and Process-Safety
It is safe to read and write the same file using FileHandler
concurrently
in multiple threads and/or processes.
Methods
impl<T> FileHandler<T>
[src]
fn open<S: AsRef<OsStr> + ?Sized>(name: &S) -> Result<FileHandler<T>, Error>
Constructor taking the required file name (not the full path) This function will return an error if the file does not exist.
This function tests whether it has write access to the file in the following locations in this order (see also an example config file flowchart):
See Thread- and Process-Safety for notes on thread- and process-safety.
fn path(&self) -> &Path
Get the full path to the file.
impl<T> FileHandler<T> where T: Default + Encodable
[src]
fn new<S: AsRef<OsStr> + ?Sized>(name: &S) -> Result<FileHandler<T>, Error>
Constructor taking the required file name (not the full path) The config file will be initialised to a default if it does not exist.
This function tests whether it has write access to the file in the following locations in this order (see also an example config file flowchart):
See Thread- and Process-Safety for notes on thread- and process-safety.
impl<T> FileHandler<T> where T: Decodable
[src]
impl<T> FileHandler<T> where T: Encodable
[src]
fn write_file(&self, contents: &T) -> Result<(), Error>
Write contents
to the file as JSON.