pub struct Configer {
pub filer: Filer,
pub human: bool,
}Expand description
Habitat Config File
Supports four serializations: HJSON, JSON, MGPK (MsgPack), and CBOR The serialization is determined by the file extension .fext which may be either ‘.json’, ‘.mgpk’, or ‘.cbor’. The default is that .json extension uses HJSON because HJSON can get (load) a strict json file. To use strict json on put (dump) then set .human to false.
Fields§
§filer: Filer§human: boolImplementations§
Source§impl Configer
impl Configer
Sourcepub fn new(
name: Option<String>,
base: Option<String>,
temp: Option<bool>,
head_dir_path: Option<PathBuf>,
perm: Option<u32>,
reopen: Option<bool>,
clear: Option<bool>,
reuse: Option<bool>,
clean: Option<bool>,
filed: Option<bool>,
extensioned: Option<bool>,
mode: Option<String>,
fext: Option<String>,
human: Option<bool>,
) -> Result<Self, HioError>
pub fn new( name: Option<String>, base: Option<String>, temp: Option<bool>, head_dir_path: Option<PathBuf>, perm: Option<u32>, reopen: Option<bool>, clear: Option<bool>, reuse: Option<bool>, clean: Option<bool>, filed: Option<bool>, extensioned: Option<bool>, mode: Option<String>, fext: Option<String>, human: Option<bool>, ) -> Result<Self, HioError>
Setup config file at path
Parameters: name: directory path name differentiator directory/file When system employs more than one keri installation, name allows differentiating each instance by name base: optional directory path segment inserted before name that allows further differentiation with a hierarchy. “” means optional. temp: assign to .temp true then open in temporary directory, clear on close Otherwise then open persistent directory, do not clear on close head_dir_path: optional head directory pathname for main database perm: optional numeric os dir permissions for database directory and database files reopen: true means (re)opened by this init, false means not (re)opened by this init but later clear: true means remove directory upon close if reopen, false means do not remove directory upon close if reopen reuse: true means reuse self.path if already exists, false means do not reuse but remake self.path clean: true means path uses clean tail variant, false means path uses normal tail variant filed: true means .path is file path not directory path, false means .path is directory path not file path mode: File open mode when filed default non-truncate r+w fext: File extension when filed human: true means use human friendly HJSON when fext is json
Sourcepub fn put<T: Serialize>(
&mut self,
data: &T,
human: Option<bool>,
) -> Result<bool, HioError>
pub fn put<T: Serialize>( &mut self, data: &T, human: Option<bool>, ) -> Result<bool, HioError>
Serialize data dict and write to file given by path where serialization is given by fext path’s extension of either JSON, MsgPack, or CBOR for extension .json, .mgpk, or .cbor respectively
Parameters: data: to be serialized per file extension on path human: override for human-friendly JSON formatting
Raises: HioError if unsupported file extension or file not opened
Sourcepub fn get<T>(&mut self, human: Option<bool>) -> Result<T, HioError>where
T: for<'de> Deserialize<'de> + Default,
pub fn get<T>(&mut self, human: Option<bool>) -> Result<T, HioError>where
T: for<'de> Deserialize<'de> + Default,
Returns data converted from contents of file path given extension Returns empty/default value if empty file
Raises: HioError if unsupported file extension or file not opened
File may be either json, msgpack, or cbor given by extension .json, .mgpk, or .cbor respectively