pub struct LibCfg {
pub scheme_sync_default: String,
pub scheme: Vec<Scheme>,
pub tmpl_html: TmplHtml,
}Expand description
Processed configuration data.
Its structure is different form the input form defined in LibCfgRaw (see
example in LIB_CONFIG_DEFAULT_TOML).
For conversion use:
use tpnote_lib::config::LIB_CONFIG_DEFAULT_TOML;
use tpnote_lib::config::LibCfg;
use tpnote_lib::config_value::CfgVal;
use std::str::FromStr;
let cfg_val = CfgVal::from_str(LIB_CONFIG_DEFAULT_TOML).unwrap();
// Run test.
let lib_cfg = LibCfg::try_from(cfg_val).unwrap();
// Check.
assert_eq!(lib_cfg.scheme_sync_default, "default")Fields§
§scheme_sync_default: StringThe fallback scheme for the sync_filename template choice, if the
scheme header variable is empty or is not defined.
scheme: Vec<Scheme>Configuration of Scheme.
tmpl_html: TmplHtmlConfiguration of HTML templates.
Implementations§
Source§impl LibCfg
impl LibCfg
Sourcepub fn scheme_idx(&self, name: &str) -> Result<usize, LibCfgError>
pub fn scheme_idx(&self, name: &str) -> Result<usize, LibCfgError>
Returns the index of a named scheme. If no scheme with that name can be
found, return LibCfgError::SchemeNotFound.
Sourcepub fn assert_validity(&self) -> Result<(), LibCfgError>
pub fn assert_validity(&self) -> Result<(), LibCfgError>
Perform some semantic consistency checks.
sort_tag.extra_separatormust NOT be insort_tag.extra_chars.sort_tag.extra_separatormust NOT be in0..9.sort_tag.extra_separatormust NOT be ina..z.sort_tag.extra_separatormust NOT be insort_tag.extra_chars.sort_tag.extra_separatormust NOTFILENAME_DOTFILE_MARKER.copy_counter.extra_separatormust be one ofsanitize_filename_reader_friendly::TRIM_LINE_CHARS.- All characters of
sort_tag.separatormust be insort_tag.extra_chars. sort_tag.separatormust start with NOTFILENAME_DOTFILE_MARKER.
Trait Implementations§
Source§impl Default for LibCfg
Reads the file ./config_default.toml (LIB_CONFIG_DEFAULT_TOML) into
LibCfg. Panics if this is not possible.
impl Default for LibCfg
Reads the file ./config_default.toml (LIB_CONFIG_DEFAULT_TOML) into
LibCfg. Panics if this is not possible.
Source§impl<'de> Deserialize<'de> for LibCfg
impl<'de> Deserialize<'de> for LibCfg
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl TryFrom<CfgVal> for LibCfg
This constructor accepts as input the newtype CfgVal containing
a toml::map::Map<String, Value>. Each String is the name of a top
level configuration variable.
The inner Map is expected to be a data structure that can be copied into
the internal temporary variable LibCfgRaw. This internal variable
is then processed and the result is stored in a LibCfg struct. For details
see the impl TryFrom<LibCfgRaw> for LibCfg. The processing occurs as
follows:
impl TryFrom<CfgVal> for LibCfg
This constructor accepts as input the newtype CfgVal containing
a toml::map::Map<String, Value>. Each String is the name of a top
level configuration variable.
The inner Map is expected to be a data structure that can be copied into
the internal temporary variable LibCfgRaw. This internal variable
is then processed and the result is stored in a LibCfg struct. For details
see the impl TryFrom<LibCfgRaw> for LibCfg. The processing occurs as
follows:
- Merge each incomplete
CfgVal(key="scheme")intoCfgVal(key="base_scheme")and store the resultingschemestruct inLibCfg.scheme. - If
CfgVal(key="html_tmpl.viewer_highlighting_css")is empty, generate the value fromCfgVal(key="tmpl.viewer_highlighting_theme"). - Do the same for
CfgVal(key="html_tmpl.exporter_highlighting_css").
Auto Trait Implementations§
impl Freeze for LibCfg
impl RefUnwindSafe for LibCfg
impl Send for LibCfg
impl Sync for LibCfg
impl Unpin for LibCfg
impl UnsafeUnpin for LibCfg
impl UnwindSafe for LibCfg
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more