pub struct FormatVariationInjector { /* private fields */ }Expand description
Format variation injector.
Implementations§
Source§impl FormatVariationInjector
impl FormatVariationInjector
Sourcepub fn new(config: FormatVariationConfig) -> Self
pub fn new(config: FormatVariationConfig) -> Self
Creates a new format variation injector.
Sourcepub fn set_country_pack(&mut self, pack: CountryPack)
pub fn set_country_pack(&mut self, pack: CountryPack)
Set the country pack for locale-aware format baselines.
When a country pack is set, the “correct” (non-varied) format for dates and amounts is derived from the pack’s locale settings instead of defaulting to ISO/Plain.
Sourcepub fn vary_date<R: Rng>(&mut self, date: NaiveDate, rng: &mut R) -> String
pub fn vary_date<R: Rng>(&mut self, date: NaiveDate, rng: &mut R) -> String
Potentially applies a date format variation.
When a country pack is set, the baseline (non-varied) format is derived
from the pack’s locale date_format.short field. Otherwise ISO 8601 is
used as the default.
Sourcepub fn vary_amount<R: Rng>(&mut self, amount: Decimal, rng: &mut R) -> String
pub fn vary_amount<R: Rng>(&mut self, amount: Decimal, rng: &mut R) -> String
Potentially applies an amount format variation.
When a country pack is set, the baseline (non-varied) format is derived from the pack’s locale number/currency settings. Otherwise plain format is used as the default.
Sourcepub fn vary_identifier<R: Rng>(&mut self, id: &str, rng: &mut R) -> String
pub fn vary_identifier<R: Rng>(&mut self, id: &str, rng: &mut R) -> String
Potentially applies an identifier format variation.
Sourcepub fn vary_text<R: Rng>(&mut self, text: &str, rng: &mut R) -> String
pub fn vary_text<R: Rng>(&mut self, text: &str, rng: &mut R) -> String
Potentially applies a text format variation.
Sourcepub fn stats(&self) -> &FormatVariationStats
pub fn stats(&self) -> &FormatVariationStats
Returns statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Resets statistics.