[−][src]Struct libzettels::Config
Config
represents the user's configuration. See "Fields" for details of
what each value represents. It bundles user specified settings from a
configuration file and can be serialized to and deserialized from such a
file.
Config
derives Serialize and Deserialize via serde
and can thus be serialized and deserialized to any format supported by
serde. See README.md for details.
The included methods from_file
and
to_file
(de)serialize from/to YAML.
Example
Minimal Configuration file (YAML)
---
rootdir: examples/Zettelkasten
indexfile: examples/index.yaml
Full Configuration file (YAML)
---
rootdir: examples/Zettelkasten
indexfile: examples/index.yaml
indexingmethod: Grep
sequencestart: Keyword
ignorefile: .gitignore
Fields
rootdir: PathBuf
The path to the root directory of the Zettelkasten, i.e. the directory containing the zettel files.
indexfile: PathBuf
The path to the index file.
indexingmethod: IndexingMethod
Optional: Indexing method
Default: IndexingMethod::Native
sequencestart: SequenceStart
Optional: Criteria how libzettels identifies a Zettel as the start of a sequence.
Default: SequenceStart::Keyword
ignorefile: PathBuf
Optional: A file specifying patterns to be ignored by the as gitignore files.
Default: By default, it is .gitignore
(because you might manage your
Zettelkasten with git).
But in case you want different ignore-patterns for git and your
Zettelkasten, you can specify an alternative file, here (e.g.
.zettelsignore
).
Implementations
impl Config
[src]
pub fn new<T: AsRef<Path>>(rootdir: T, indexfile: T) -> Config
[src]
Creates a new Config by specifying a root directory and a file name for the index file as strings.
Example
let cfg = Config::new("examples/Zettelkasten", "examples/index.yaml"); assert_eq!(&cfg.rootdir, Path::new("examples/Zettelkasten")); assert_eq!(&cfg.indexfile, Path::new("examples/index.yaml")); assert_eq!(&cfg.ignorefile, Path::new(".gitignore"));
pub fn from_file<P: AsRef<Path>>(configfile: P) -> Result<Config, Error>
[src]
Creates a new Config by deserializing it from a YAML-file.
Example
let cfg = Config::from_file(Path::new("examples/zettels-examples.cfg.yaml"))?;
Errors
Error::Io
for problems with the specified file.Error::Yaml
for problems deserializing from YAML.
pub fn to_file<P: AsRef<Path>>(&self, configfile: P) -> Result<(), Error>
[src]
Serializes the Config self
to a YAML-file.
Example
let cfg = Config::new("examples/Zettelkasten", "examples/index.yaml"); match cfg.to_file(Path::new("examples/zettels-examples.cfg.yaml")) { Ok(_) => println!("Saved config."), Err(error) => panic!("Failed to write config to file. {}", error), };
Errors
Error::Io
for problems with the specified file.Error::Yaml
for problems serializing to YAML.
Trait Implementations
impl Debug for Config
[src]
impl<'de> Deserialize<'de> for Config
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl PartialEq<Config> for Config
[src]
impl Serialize for Config
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralPartialEq for Config
[src]
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,