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.
Auto Trait Implementations§
impl Freeze for FormatVariationInjector
impl RefUnwindSafe for FormatVariationInjector
impl Send for FormatVariationInjector
impl Sync for FormatVariationInjector
impl Unpin for FormatVariationInjector
impl UnsafeUnpin for FormatVariationInjector
impl UnwindSafe for FormatVariationInjector
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.