Struct LibCfg

Source
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: String

The 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: TmplHtml

Configuration of HTML templates.

Implementations§

Source§

impl LibCfg

Source

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.

Source

pub fn assert_validity(&self) -> Result<(), LibCfgError>

Perform some semantic consistency checks.

  • sort_tag.extra_separator must NOT be in sort_tag.extra_chars.
  • sort_tag.extra_separator must NOT be in 0..9.
  • sort_tag.extra_separator must NOT be in a..z.
  • sort_tag.extra_separator must NOT be in sort_tag.extra_chars.
  • sort_tag.extra_separator must NOT FILENAME_DOTFILE_MARKER.
  • copy_counter.extra_separator must be one of sanitize_filename_reader_friendly::TRIM_LINE_CHARS.
  • All characters of sort_tag.separator must be in sort_tag.extra_chars.
  • sort_tag.separator must start with NOT FILENAME_DOTFILE_MARKER.

Trait Implementations§

Source§

impl Debug for LibCfg

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LibCfg

Reads the file ./config_default.toml (LIB_CONFIG_DEFAULT_TOML) into LibCfg. Panics if this is not possible.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for LibCfg

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for LibCfg

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
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:

  1. Merge each incomplete CfgVal(key="scheme") into CfgVal(key="base_scheme") and store the resulting scheme struct in LibCfg.scheme.
  2. If CfgVal(key="html_tmpl.viewer_highlighting_css") is empty, generate the value from CfgVal(key="tmpl.viewer_highlighting_theme").
  3. Do the same for CfgVal(key="html_tmpl.exporter_highlighting_css").
Source§

type Error = LibCfgError

The type returned in the event of a conversion error.
Source§

fn try_from(cfg_val: CfgVal) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for LibCfg

§

impl RefUnwindSafe for LibCfg

§

impl Send for LibCfg

§

impl Sync for LibCfg

§

impl Unpin for LibCfg

§

impl UnwindSafe for LibCfg

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,