Struct config_file_handler::FileHandler [−][src]
pub struct FileHandler<T> { /* 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]
impl<T> FileHandler<T>
pub fn open<S: AsRef<OsStr> + ?Sized>(
name: &S,
assert_writable: bool
) -> Result<FileHandler<T>, Error>
[src]
pub fn open<S: AsRef<OsStr> + ?Sized>(
name: &S,
assert_writable: bool
) -> 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] (https://github.com/maidsafe/crust/blob/master/docs/vault_config_file_flowchart.pdf)):
Parameter assert_writable
dictates if the file should be writable or not.
See Thread- and Process-Safety for notes on thread- and process-safety.
pub fn path(&self) -> &Path
[src]
pub fn path(&self) -> &Path
Get the full path to the file.
impl<T> FileHandler<T> where
T: Default + Serialize,
[src]
impl<T> FileHandler<T> where
T: Default + Serialize,
pub fn new<S: AsRef<OsStr> + ?Sized>(
name: &S,
is_existing_file_writable: bool
) -> Result<FileHandler<T>, Error>
[src]
pub fn new<S: AsRef<OsStr> + ?Sized>(
name: &S,
is_existing_file_writable: bool
) -> 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 read access to the file in the following locations in this order (see also [an example config file flowchart] (https://github.com/maidsafe/crust/blob/master/docs/vault_config_file_flowchart.pdf)):
Parameter is_existing_file_writable
will assert that if the file pre-exists should it be
also writable or not. (E.g. it is enough for crust-config
file to merely exist as
readable, but bootstrap-cache
must be writable too if it exists, else no updation can
happen).
See Thread- and Process-Safety for notes on thread- and process-safety.
impl<T> FileHandler<T> where
T: DeserializeOwned,
[src]
impl<T> FileHandler<T> where
T: DeserializeOwned,
pub fn read_file(&self) -> Result<T, Error>
[src]
pub fn read_file(&self) -> Result<T, Error>
Read the contents of the file and decode it as JSON.
impl<T> FileHandler<T> where
T: Serialize,
[src]
impl<T> FileHandler<T> where
T: Serialize,
Auto Trait Implementations
impl<T> Send for FileHandler<T> where
T: Send,
impl<T> Send for FileHandler<T> where
T: Send,
impl<T> Sync for FileHandler<T> where
T: Sync,
impl<T> Sync for FileHandler<T> where
T: Sync,