random-data
A Rust library for generating realistic random data of any kind.
Looking for a CLI?
Checkout the random-json
crate to use this data as a CLI. It let's you choose the data you want with a dropdown dialogue in the terminal, or lets you generate big amounts of data in one go from a JSON schema!
Installation
Usage
use ;
Checking Available Values
Some data types have predefined lists of values. You can access these lists:
use ;
let mut generator = new;
// Check if a data type has a predefined list
if let Some = Month.values
// Formula-based types return None
assert!;
// Generate and verify
let month = Month.random;
let all_months = Month.values.unwrap;
assert!;
Regional Data
The library includes region-specific generators:
use ;
let mut generator = new;
// UK-specific data
let uk_address = UkAddress.random;
let uk_postcode = UkPostCode.random;
let uk_phone = UkPhoneNumber.random;
// French-specific data
let french_address = FrenchAddress.random;
let french_postcode = FrenchPostCode.random;
let french_phone = FrenchPhoneNumber.random;
Available Data Types
- Internet: EmailDomain, HttpStatusCode, MimeType, OpenSourceApp, TopLevelDomain, UserAgent, Ipv4, Ipv6, MacAddress
- Companies: CarBrand, CompanyName, Job
- Computer science: FileExtension, ProgrammingLanguage, ProgrammingParadigm, EditorColourTheme, ItDomain, DirPath, FileName, FilePath, Semver, SemverStable, SemverUnstable
- Famous people: Painter, Writer, Composer, Mathematician, Physician, Biologist, ComputerScientist, Philosopher
- Colours: HexColour, HslaColour, HslColour, RgbaColour, RgbColour, ColourName
- Geography: Latitude, LatitudeLongitude, Longitude, FrenchRiver, Country, City, Continent, CountryCode, Street, River, UkRiver
- Addresses: Address, FrenchAddress, FrenchPostCode, UkAddress, UkPostCode, FrenchStreet, FrenchRoadType, FrenchCounty, UsStateAbbr, UsState, UsRoads, UsRoadTypes, UkCountyCode, UkPostcodeArea, UkCounty, UkCity, UkRoadType, UkStreet, StreetNumber
- Science: ChemicalElement, MathematicalFunction
- Names: FirstName, FrenchFirstName, FrenchLastName, LastName, NameTitle
- Arts: LiteraryGenre, ArchitecturalStyle, MusicalGenre, MusicalInstrument
- Time: DaysOfWeek, Month, DaysOfWeekAbbr, MonthsAbbr, TimeZone, TimeUnit, AmPm
- Animals: Animal, Mammal, Bird, Insect, MythologicalCreature, Fish, Amphibian, Reptile, Mollusc, AnimalType
- Education: SchoolSubject, AcademicDiscipline, DegreesTitle, University, HistoricalBattle, Sport
- Primitives: AlphanumericCapitalChar, AlphanumericChar, Boolean, CapitalChar, Digit, LowerChar
- Personal data: CreditCard, Email, FrenchEmail, FrenchLicencePlate, FrenchPhoneNumber, NhsNumber, Password, PhoneNumber, SecuriteSociale, UkLicencePlate, UkPhoneNumber
- ISBNs: RandomIsbn10, RandomIsbn13
- Banks & finance: Bic, Iban, Isin, CurrencyName, CurrencySymbol, CurrencyCode
- Text: Word, Sentence, Paragraph
- Sky & space: Constellation, Planet, Star, Galaxy, CloudType
If you don't want all the data to be loaded in your binary, you can use the feature flags to disable those you don't want.