Skip to main content

GenContext

Struct GenContext 

Source
pub struct GenContext<'a> {
    pub rng: Rng,
    pub locales: &'a [&'a Locale],
    pub modifier: &'a str,
    pub identity: Option<&'a Identity>,
    pub tz_offset_minutes: i32,
    pub since: i64,
    pub until: i64,
    pub range: Option<(i64, i64)>,
    pub ordering: Ordering,
    pub zipf: Option<ZipfSpec>,
    pub numeric: Option<f64>,
}
Expand description

Generation context — replaces globals and rigid GenFn params.

Fields§

§rng: Rng§locales: &'a [&'a Locale]§modifier: &'a str§identity: Option<&'a Identity>§tz_offset_minutes: i32§since: i64§until: i64§range: Option<(i64, i64)>

Per-field range override, resolved (both bounds filled).

§ordering: Ordering

Monotonic ordering: Asc/Desc use record number for position.

§zipf: Option<ZipfSpec>

Zipf distribution over the range. None = uniform.

§numeric: Option<f64>

Raw numeric value — set by numeric generators, read by aggregators.

Implementations§

Source§

impl<'a> GenContext<'a>

Source

pub fn locale(&mut self) -> &'a Locale

Locale locked to Identity when ctx active, otherwise random.

Source

pub fn pick_locale(&mut self) -> &'a Locale

Always random locale pick (ignores identity).

Source

pub fn tz_log(&self, buf: &mut String)

TZ offset for Apache log: “+HHMM” / “-HHMM”

Source

pub fn tz_iso(&self, buf: &mut String)

TZ offset for ISO 8601: “Z” or “+HH:MM” / “-HH:MM”

Auto Trait Implementations§

§

impl<'a> Freeze for GenContext<'a>

§

impl<'a> RefUnwindSafe for GenContext<'a>

§

impl<'a> Send for GenContext<'a>

§

impl<'a> Sync for GenContext<'a>

§

impl<'a> Unpin for GenContext<'a>

§

impl<'a> UnsafeUnpin for GenContext<'a>

§

impl<'a> UnwindSafe for GenContext<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.