Expand description
Random value generation and randomized truncation helpers.
These helpers use the thread-local generator for strings, indexes, shuffles, durations, and event identifiers. Range arguments use half-open semantics.
Re-exportsยง
use std::iter::repeat_with;๐use std::ops::Range;๐use std::time::Duration;๐use std::time::SystemTime;๐use arrayvec::ArrayString;๐use rand::RngExt;๐use rand::rng;๐use rand::seq::SliceRandom;๐use ruma::OwnedEventId;๐
Functionsยง
- event_
id - Generates a Matrix event identifier from 32 random bytes.
- index
- Chooses a uniformly random index below
len. - secs
- Generates a
Durationwith a random whole-second length. - shuffle
- Randomly permutes a slice in place.
- string
- Generates an alphanumeric ASCII string of the requested byte length.
- string_
array - Generates an alphanumeric ASCII string that fills a fixed-capacity array.
- string_
from - Generates a string of
lengthcharacters sampled fromcharset. - time_
from_ now_ secs - Adds a random whole-second offset to the current
SystemTime. - truncate_
str - Borrows a prefix ending at a randomly selected character count.
- truncate_
string - Truncates an owned string at a randomly selected character count.