[][src]Struct guidon::Guidon

pub struct Guidon<'a> { /* fields omitted */ }

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]

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 a Hashmap<String, String> as parameter and returns a HashMap<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]

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 a String parameter and returns the value to use as a String.

pub fn apply_template<F, T>(&mut self, from_dir: F, to_dir: T) -> Result<()> where
    F: AsRef<Path>,
    T: AsRef<Path>, 
[src]

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. If use_template_dir is set to true (default value), the template will be searched for in from_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]

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.