pub struct SpecTemplate {
pub name: String,
pub frontmatter: TemplateFrontmatter,
pub body: String,
pub source: TemplateSource,
pub path: PathBuf,
}Expand description
A spec template with its metadata and content
Fields§
§name: StringTemplate name
frontmatter: TemplateFrontmatterParsed frontmatter
body: StringTemplate body (with {{variable}} placeholders)
source: TemplateSourceSource location (project or global)
path: PathBufFile path where template was loaded from
Implementations§
Source§impl SpecTemplate
impl SpecTemplate
Sourcepub fn parse(content: &str, path: &Path, source: TemplateSource) -> Result<Self>
pub fn parse(content: &str, path: &Path, source: TemplateSource) -> Result<Self>
Parse a template from file content.
Sourcepub fn load(path: &Path, source: TemplateSource) -> Result<Self>
pub fn load(path: &Path, source: TemplateSource) -> Result<Self>
Load a template from a file path.
Sourcepub fn required_variables(&self) -> Vec<&TemplateVariable>
pub fn required_variables(&self) -> Vec<&TemplateVariable>
Get list of required variables that don’t have defaults
Sourcepub fn validate_variables(
&self,
provided: &HashMap<String, String>,
) -> Result<()>
pub fn validate_variables( &self, provided: &HashMap<String, String>, ) -> Result<()>
Check if all required variables are provided
Trait Implementations§
Source§impl Clone for SpecTemplate
impl Clone for SpecTemplate
Source§fn clone(&self) -> SpecTemplate
fn clone(&self) -> SpecTemplate
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SpecTemplate
impl RefUnwindSafe for SpecTemplate
impl Send for SpecTemplate
impl Sync for SpecTemplate
impl Unpin for SpecTemplate
impl UnwindSafe for SpecTemplate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more