seedfaker-core 0.4.0-alpha.1

Core library for seedfaker — deterministic synthetic generator for realistic, correlated, and noisy test records
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::ctx::GenContext;

pub fn gen(ctx: &mut GenContext<'_>, buf: &mut String) {
    let digits = ctx.rng.digits(11);
    if ctx.modifier == "plain" {
        buf.push_str(&digits);
    } else {
        buf.reserve(14);
        buf.push_str(&digits[0..3]);
        buf.push('.');
        buf.push_str(&digits[3..6]);
        buf.push('.');
        buf.push_str(&digits[6..9]);
        buf.push('-');
        buf.push_str(&digits[9..11]);
    }
}