Struct ForgeTemplate

Source
pub struct ForgeTemplate<S: ToString, T: Serialize> { /* private fields */ }

Implementations§

Source§

impl<S: ToString, T: Serialize> ForgeTemplate<S, T>

Source

pub fn new(name: S, path: PathBuf, default_data: T) -> Self

Examples found in repository?
examples/common/utils.rs (lines 20-24)
8pub fn create_forge(preview: bool) -> Forge<Templates, Value> {
9    let config = ForgeConfig {
10        components_dir_path: PathBuf::from("examples/components/"),
11        components_dir_options: DirectorySourceOptions::default(),
12        preview,
13    };
14
15    let mut forge: Forge<Templates, Value> = Forge::new(config).unwrap();
16
17    let template = Templates::EmailValidation(Default::default());
18    if let Templates::EmailValidation(data) = &template {
19        forge
20            .add_template(ForgeTemplate::new(
21                template.clone(),
22                PathBuf::from_str("examples/templates/email_validation.hbs").unwrap(),
23                serde_json::to_value(data.clone()).unwrap(),
24            ))
25            .unwrap();
26    }
27
28    let template = Templates::PasswordReset(Default::default());
29    if let Templates::PasswordReset(data) = &template {
30        forge
31            .add_template(ForgeTemplate::new(
32                template.clone(),
33                PathBuf::from_str("examples/templates/password_reset.hbs").unwrap(),
34                serde_json::to_value(data.clone()).unwrap(),
35            ))
36            .unwrap();
37    }
38
39    forge
40}
Source

pub fn get_path(&self) -> &PathBuf

Source

pub fn get_name(&self) -> &str

Source

pub fn get_default_data(&self) -> &T

Auto Trait Implementations§

§

impl<S, T> Freeze for ForgeTemplate<S, T>
where T: Freeze,

§

impl<S, T> RefUnwindSafe for ForgeTemplate<S, T>

§

impl<S, T> Send for ForgeTemplate<S, T>
where T: Send, S: Send,

§

impl<S, T> Sync for ForgeTemplate<S, T>
where T: Sync, S: Sync,

§

impl<S, T> Unpin for ForgeTemplate<S, T>
where T: Unpin, S: Unpin,

§

impl<S, T> UnwindSafe for ForgeTemplate<S, T>
where T: UnwindSafe, S: UnwindSafe,

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, 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.