Skip to main content

GeneratorKind

Enum GeneratorKind 

Source
#[non_exhaustive]
pub enum GeneratorKind {
Show 42 variants IntPrimaryKey, Int, Float, Bool, Text, FirstName, LastName, FullName, Email, Phone, City, Country, Address, JobTitle, Title, Url, Username, Slug, Company, LoremIpsum, Uuid, Json, Date, Timestamp, Time, TimeTz, Interval, Blob, PgInet, PgCidr, PgMacAddr, PgMacAddr8, PgPoint, PgLine, PgLseg, PgBox, PgPath, PgPolygon, PgCircle, PgBit, PgVarBit, PgArray,
}
Expand description

A built-in generator, chosen by type/name inference or set with SeedConfig::kind.

New kinds may be added in any release, so a match on it needs a _ arm.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

IntPrimaryKey

Sequential integers starting at 1 (row index + 1).

§

Int

Random integer from 0 to 10 000.

§

Float

Random number from 0 up to 10 000, rounded to 2 decimals.

§

Bool

Random boolean.

§

Text

5 to 50 random lowercase letters.

§

FirstName

First name from a built-in list.

§

LastName

Last name from a built-in list.

§

FullName

First and last name.

§

Email

first.last{row}@example.com (or another domain reserved for testing); the row index keeps emails unique.

§

Phone

US-style phone number, (555) 555-5555.

§

City

City name from a built-in list.

§

Country

Country name from a built-in list.

§

Address

Street address, 123 Name Street.

§

JobTitle

Job title from a built-in list.

§

Title

A short sentence-case phrase, such as a post title: Dolor sit amet.

§

Url

https:// URL on a reserved example domain; the row index keeps URLs unique.

§

Username

Lowercase first_last{row}; the row index keeps usernames unique.

§

Slug

URL slug, dolor-sit-amet-{row}; the row index keeps slugs unique.

§

Company

Company name: a last name and a suffix, such as Smith Inc.

§

LoremIpsum

Ten words of lorem ipsum.

§

Uuid

Random UUID v4 as text (8-4-4-4-12 hex).

§

Json

Small JSON object as text.

§

Date

Date between 2000 and 2030 as YYYY-MM-DD; for an integer column type, its Unix milliseconds (UTC midnight) instead.

§

Timestamp

Timestamp between 2000 and 2030 as YYYY-MM-DD HH:MM:SS; for an integer column type, its Unix milliseconds (UTC) instead.

§

Time

Time of day, HH:MM:SS.

§

TimeTz

Time of day with a UTC offset, HH:MM:SS+HH.

§

Interval

PostgreSQL interval of 1 to 72 hours, such as "12 hours".

§

Blob

32 random bytes.

§

PgInet

PostgreSQL INET

§

PgCidr

PostgreSQL CIDR

§

PgMacAddr

PostgreSQL MACADDR

§

PgMacAddr8

PostgreSQL MACADDR8

§

PgPoint

PostgreSQL POINT

§

PgLine

PostgreSQL LINE

§

PgLseg

PostgreSQL LSEG

§

PgBox

PostgreSQL BOX

§

PgPath

PostgreSQL PATH

§

PgPolygon

PostgreSQL POLYGON

§

PgCircle

PostgreSQL CIRCLE

§

PgBit

PostgreSQL BIT: 8 random bits.

§

PgVarBit

PostgreSQL VARBIT: 1 to 32 random bits.

§

PgArray

PostgreSQL array: always the empty array literal {}.

Implementations§

Source§

impl GeneratorKind

Source

pub fn into_generator(self) -> Box<dyn Generator>

Returns the generator for this kind.

Trait Implementations§

Source§

impl Clone for GeneratorKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for GeneratorKind

Source§

impl Debug for GeneratorKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for GeneratorKind

Source§

impl Generator for GeneratorKind

A built-in kind is itself a generator, so it can be passed wherever a Generator is expected.

Source§

fn generate( &self, rng: &mut dyn RngCore, index: usize, sql_type: &str, ) -> SeedValue

Returns the value for row index (0-based). sql_type is the column’s SQL type as declared, e.g. "INTEGER" or "TEXT".
Source§

fn name(&self) -> &'static str

Returns a short name for debugging. Defaults to the type name.
Source§

impl PartialEq for GeneratorKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GeneratorKind

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<G> GeneratorExt for G
where G: Generator,

Source§

fn nullable(self, probability: f64) -> Nullable<Self>

Returns NULL with the given probability (0.0 to 1.0), otherwise a value from self. Read more
Source§

fn map<F, V>(self, f: F) -> Map<Self, F>
where F: Fn(SeedValue) -> V + Send + Sync, V: Into<SeedValue>,

Transforms each generated value with f.
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<Joined, From> JoinKey<From, JoinReverse> for Joined
where From: Joinable<Joined> + ?Sized,

Source§

fn pairs() -> &'static [(&'static str, &'static str)]

(joined_column, from_column) pairs the ON condition matches, in key order, read through Self::pair.
Source§

fn pair(pair: &(&'static str, &'static str)) -> (&'static str, &'static str)

The (joined_column, from_column) names of pair.
Source§

impl<List> ListIncludes<Nil, ()> for List

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> TypeEq<T> for T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V