[−][src]Struct guidon::Guidon
The Guidon structure
Methods
impl<'a> Guidon<'a>
[src]
pub fn new() -> Result<Self>
[src]
Initializes guidon with default settings. The template file path is set to template.toml
pub fn with_conf<P: AsRef<Path>>(conf_file: P) -> Result<Self>
[src]
Initializes guidon with the provided configuration file
Arguments
conf_file
: the given configuration file, as path reference
Example
use guidon::Guidon; let guidon = Guidon::with_conf("my/config.toml").unwrap();
pub fn set_variables_callback<F>(&mut self, cb: F) where
F: Fn(&mut HashMap<String, String>) + 'a,
[src]
F: Fn(&mut HashMap<String, String>) + 'a,
Provides a callback to perform an operation on the variables map. Can be used to change default variables values.
Arguments
cb
: callback. A closure with takes aHashmap<String, String>
as parameter and returns aHashMap<String, String>
.
Example
use guidon::Guidon; use std::collections::HashMap; let cb = |h: &mut HashMap<String, String>| { h.iter_mut().for_each(|(_, v)| *v +=" cb"); }; let mut guidon = Guidon::new().unwrap(); guidon.set_variables_callback(cb);
pub fn set_render_callback<F>(&mut self, cb: F) where
F: Fn(String) -> String + 'a,
[src]
F: Fn(String) -> String + 'a,
Provides a callback to be called when a variables is not found in the configuration file.
This currently doesn't work
Arguments
cb
: callback. A closure with takes the expected key as aString
parameter and returns the value to use as aString
.
pub fn apply_template<F, T>(&mut self, from_dir: F, to_dir: T) -> Result<()> where
F: AsRef<Path>,
T: AsRef<Path>,
[src]
F: AsRef<Path>,
T: AsRef<Path>,
Apply template. The substitution will be performed with variables provided in the config file.
Arguments
from_dir
: the directory where the template files are located. Ifuse_template_dir
is set totrue
(default value), the template will be searched for infrom_dir/template
.to_dir
: the directory where the templated file structure will be created.
Trait Implementations
impl<'de, 'a> Deserialize<'de> for Guidon<'a>
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Guidon<'a>
impl<'a> !Send for Guidon<'a>
impl<'a> !Sync for Guidon<'a>
impl<'a> Unpin for Guidon<'a>
impl<'a> !UnwindSafe for Guidon<'a>
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>,