pub struct TemplateLoader;Expand description
Template loader for reading and validating template files.
Implementations§
Source§impl TemplateLoader
impl TemplateLoader
Sourcepub fn load_from_yaml(path: &Path) -> Result<TemplateData, TemplateError>
pub fn load_from_yaml(path: &Path) -> Result<TemplateData, TemplateError>
Load template data from a YAML file.
Sourcepub fn load_from_yaml_str(yaml: &str) -> Result<TemplateData, TemplateError>
pub fn load_from_yaml_str(yaml: &str) -> Result<TemplateData, TemplateError>
Load template data from an in-memory YAML string. v4.0.0+.
Intended for callers that embed template YAML at compile time
via include_str!("…"), which is the primary migration step
toward v4.1’s planned YAML-as-source-of-truth for the default
name pools.
Sourcepub fn load_from_json(path: &Path) -> Result<TemplateData, TemplateError>
pub fn load_from_json(path: &Path) -> Result<TemplateData, TemplateError>
Load template data from a JSON file.
Sourcepub fn load_from_file(path: &Path) -> Result<TemplateData, TemplateError>
pub fn load_from_file(path: &Path) -> Result<TemplateData, TemplateError>
Load template data from a file (auto-detect format by extension).
Sourcepub fn save_to_yaml(
data: &TemplateData,
path: &Path,
) -> Result<(), TemplateError>
pub fn save_to_yaml( data: &TemplateData, path: &Path, ) -> Result<(), TemplateError>
Save template data to a YAML file. v3.5.0+ — used by
datasynth-data templates enrich to persist LLM-enriched pools.
Creates the parent directory if it doesn’t exist.
Sourcepub fn save_to_file(
data: &TemplateData,
path: &Path,
) -> Result<(), TemplateError>
pub fn save_to_file( data: &TemplateData, path: &Path, ) -> Result<(), TemplateError>
Save template data to a file (auto-detect format by extension). v3.5.0+.
Sourcepub fn load_from_directory(dir: &Path) -> Result<TemplateData, TemplateError>
pub fn load_from_directory(dir: &Path) -> Result<TemplateData, TemplateError>
Load all template files from a directory.
Sourcepub fn validate(data: &TemplateData) -> Vec<String>
pub fn validate(data: &TemplateData) -> Vec<String>
Validate template data.
Sourcepub fn merge(
base: TemplateData,
overlay: TemplateData,
strategy: MergeStrategy,
) -> TemplateData
pub fn merge( base: TemplateData, overlay: TemplateData, strategy: MergeStrategy, ) -> TemplateData
Merge two template data sets according to the specified strategy.
Auto Trait Implementations§
impl Freeze for TemplateLoader
impl RefUnwindSafe for TemplateLoader
impl Send for TemplateLoader
impl Sync for TemplateLoader
impl Unpin for TemplateLoader
impl UnsafeUnpin for TemplateLoader
impl UnwindSafe for TemplateLoader
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.