Crates.io | datagen-rs |
lib.rs | datagen-rs |
version | 0.1.0 |
source | src |
created_at | 2023-09-25 15:38:27.206127 |
updated_at | 2023-09-25 15:38:27.206127 |
description | A random data generator written in rust |
homepage | |
repository | https://github.com/MarkusJx/datagen |
max_upload_size | |
id | 982830 |
size | 154,443 |
A Rust library for generating random data from a JSON schema.
Add the following to your Cargo.toml
:
[dependencies]
datagen-rs = "0.1.0"
use datagen_rs::util::helpers::{generate_random_data, read_schema};
fn main() {
let schema = read_schema("path/to/schema.json").unwrap();
let data = generate_random_data(schema, None).unwrap();
println!("{}", data);
}
use datagen_rs::util::helpers::{generate_random_data_from_str, read_schema};
fn main() {
let schema: Schema = serde_json::from_str(r#"
{
"type": "string",
"value": "test
}
"#).unwrap();
let data = generate_random_data_from_str(&schema, None).unwrap();
println!("{}", data);
}
use datagen_rs::util::helpers::write_json_schema;
fn main() {
write_json_schema("path/to/schema.json").unwrap();
}
Feature | Description | Depends on |
---|---|---|
plugin |
Enables loading plugins | |
native-plugin |
Enables loading plugins written in Rust | plugin |
serialize |
Enables serialization/deserialization for all structs using serde . |
|
map-schema |
Enables data generation for several types | serialize |
generate |
Enables data generation for all types | map-schema |
schema |
Enables JSON schema generation using schemars |
serialize |
all |
Enables all features | native-plugin , generate , schema |