pub trait DocxTemplate {
// Required methods
fn template_path(&self) -> &Path;
fn replacements(&self) -> Vec<(&str, &str)>;
fn to_bytes(&self) -> Result<Vec<u8>, TemplateError>;
// Provided method
fn save(&self, path: &Path) -> Result<(), TemplateError> { ... }
}Expand description
Trait implemented by all generated template structs.
Enables polymorphic use of templates via &dyn DocxTemplate or generics:
ⓘ
use docxide_template::DocxTemplate;
fn process(template: &dyn DocxTemplate) -> Result<Vec<u8>, docxide_template::TemplateError> {
template.to_bytes()
}Required Methods§
Sourcefn template_path(&self) -> &Path
fn template_path(&self) -> &Path
Returns the filesystem path to the original .docx template.
Sourcefn replacements(&self) -> Vec<(&str, &str)>
fn replacements(&self) -> Vec<(&str, &str)>
Returns the list of (placeholder, value) pairs for substitution.