pub struct DefaultTemplateProvider { /* private fields */ }Expand description
Default template provider using embedded templates with optional file overrides.
Implementations§
Source§impl DefaultTemplateProvider
impl DefaultTemplateProvider
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new provider backed by the bundled defaults.yaml.
As of v4.2.4 this is a thin alias for Self::bundled: the YAML
bundled via include_str! is the sole source of truth for the
default name pools. Parse failure would mean defaults.yaml is
malformed, which build.rs validates at compile time — so the
.expect below is effectively infallible for any shipped build.
Sourcepub fn bundled() -> Result<Self, TemplateError>
pub fn bundled() -> Result<Self, TemplateError>
Create a provider backed directly by the bundled defaults.yaml
(included at compile time via include_str!).
Equivalent to Self::new but surfaces the parse Result for
callers that want to handle malformed YAML explicitly (e.g. tests
that validate the loader against hand-crafted malformed inputs).
Sourcepub fn with_templates(
template_data: TemplateData,
strategy: MergeStrategy,
) -> Self
pub fn with_templates( template_data: TemplateData, strategy: MergeStrategy, ) -> Self
Create a provider with user-supplied template data.
The data replaces the bundled defaults wholesale. Callers who want
to merge custom content on top of the bundled defaults should
start from Self::new and use TemplateLoader::merge / the
MergeStrategy::Extend path explicitly.
Sourcepub fn from_file(path: &Path) -> Result<Self, TemplateError>
pub fn from_file(path: &Path) -> Result<Self, TemplateError>
Load templates from a file path.
Sourcepub fn from_directory(path: &Path) -> Result<Self, TemplateError>
pub fn from_directory(path: &Path) -> Result<Self, TemplateError>
Load templates from a directory.
Sourcepub fn with_merge_strategy(self, strategy: MergeStrategy) -> Self
pub fn with_merge_strategy(self, strategy: MergeStrategy) -> Self
Set the merge strategy.
Trait Implementations§
Source§impl Default for DefaultTemplateProvider
impl Default for DefaultTemplateProvider
Source§impl TemplateProvider for DefaultTemplateProvider
impl TemplateProvider for DefaultTemplateProvider
Source§fn get_person_first_name(
&self,
culture: NameCulture,
is_male: bool,
rng: &mut dyn Rng,
) -> String
fn get_person_first_name( &self, culture: NameCulture, is_male: bool, rng: &mut dyn Rng, ) -> String
Source§fn get_person_last_name(
&self,
culture: NameCulture,
rng: &mut dyn Rng,
) -> String
fn get_person_last_name( &self, culture: NameCulture, rng: &mut dyn Rng, ) -> String
Source§fn get_vendor_name(&self, category: &str, rng: &mut dyn Rng) -> String
fn get_vendor_name(&self, category: &str, rng: &mut dyn Rng) -> String
Source§fn get_customer_name(&self, industry: &str, rng: &mut dyn Rng) -> String
fn get_customer_name(&self, industry: &str, rng: &mut dyn Rng) -> String
Source§fn get_material_description(
&self,
material_type: &str,
rng: &mut dyn Rng,
) -> String
fn get_material_description( &self, material_type: &str, rng: &mut dyn Rng, ) -> String
Source§fn get_asset_description(&self, category: &str, rng: &mut dyn Rng) -> String
fn get_asset_description(&self, category: &str, rng: &mut dyn Rng) -> String
Source§fn get_line_text(
&self,
process: BusinessProcess,
account_type: &str,
rng: &mut dyn Rng,
) -> String
fn get_line_text( &self, process: BusinessProcess, account_type: &str, rng: &mut dyn Rng, ) -> String
Source§fn get_header_template(
&self,
process: BusinessProcess,
rng: &mut dyn Rng,
) -> String
fn get_header_template( &self, process: BusinessProcess, rng: &mut dyn Rng, ) -> String
Source§fn get_bank_name(&self, rng: &mut dyn Rng) -> Option<String>
fn get_bank_name(&self, rng: &mut dyn Rng) -> Option<String>
Source§fn get_finding_title(
&self,
finding_type_key: &str,
rng: &mut dyn Rng,
) -> Option<(String, String)>
fn get_finding_title( &self, finding_type_key: &str, rng: &mut dyn Rng, ) -> Option<(String, String)>
Auto Trait Implementations§
impl Freeze for DefaultTemplateProvider
impl RefUnwindSafe for DefaultTemplateProvider
impl Send for DefaultTemplateProvider
impl Sync for DefaultTemplateProvider
impl Unpin for DefaultTemplateProvider
impl UnsafeUnpin for DefaultTemplateProvider
impl UnwindSafe for DefaultTemplateProvider
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.