warlocks_cauldron/providers/science.rs
1use super::dependencies::*;
2
3
4/// Methods collection for generating pseudo-scientific data
5pub struct Science;
6
7impl Science {
8 /// Generate a random RNA sequence
9 ///
10 /// Arguments:
11 /// * `length` - Length of block
12 pub fn rna_sequence(length: usize) -> String {
13 generate_string("UCGA", length)
14 }
15
16 /// Generate a random DNA sequence
17 ///
18 /// Arguments:
19 /// * `length` - Length of block
20 pub fn dna_sequence(length: usize) -> String {
21 generate_string("TCGA", length)
22 }
23
24 /// Get unit name from International System of Units
25 ///
26 /// ex: ("gram", "gr")
27 pub fn measure_unit() -> (&'static str, &'static str) {
28 get_random_element(MeasureUnit::values().into_iter())
29 }
30
31 /// Get a random prefix for the International System of Units
32 ///
33 /// ex: nano
34 ///
35 /// Arguments:
36 /// * `sign` - Sing of prefix (positive/negative) or None for random
37 /// * `symbol` - Return the symbol of the prefix
38 pub fn metric_prefix(sign: Option<MetricPrefixSign>, symbol: bool) -> &'static str {
39 let key = validate_enum(sign, None);
40 match symbol {
41 true => get_random_element(SI_PREFIXES_SYM.get(key).expect("Cant find SI_PREFIX_SYM!").iter()),
42 false => get_random_element(SI_PREFIXES.get(key).expect("Cant find SI_PREFIX!").iter()),
43 }
44 }
45}