faker_rust/default/
drone.rs1use crate::base::sample;
4use crate::locale::fetch_locale;
5
6pub fn manufacturer() -> String {
8 fetch_locale("drone.manufacturers", "en")
9 .map(|v| sample(&v))
10 .unwrap_or_else(|| sample(FALLBACK_MANUFACTURERS).to_string())
11}
12
13pub fn name() -> String {
15 fetch_locale("drone.names", "en")
16 .map(|v| sample(&v))
17 .unwrap_or_else(|| sample(FALLBACK_NAMES).to_string())
18}
19
20pub fn category() -> String {
22 fetch_locale("drone.categories", "en")
23 .map(|v| sample(&v))
24 .unwrap_or_else(|| sample(FALLBACK_CATEGORIES).to_string())
25}
26
27const FALLBACK_MANUFACTURERS: &[&str] = &[
29 "DJI", "Parrot", "Autel Robotics", "Skydio", "Yuneec", "Holy Stone",
30 "Ryze", "Hubsan", "Syma", "Potensic", "Snaptain", "DEERC",
31];
32
33const FALLBACK_NAMES: &[&str] = &[
34 "Mavic Air", "Mavic Pro", "Phantom", "Inspire", "Mini", "Spark",
35 "Anafi", "Bebop", "EVO", "X-Star", "Typhoon", "Tello",
36];
37
38const FALLBACK_CATEGORIES: &[&str] = &[
39 "Consumer", "Professional", "Racing", "Toy", "Industrial", "Military",
40 "Agricultural", "Delivery", "Surveillance", "Photography",
41];
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_manufacturer() {
49 assert!(!manufacturer().is_empty());
50 }
51
52 #[test]
53 fn test_name() {
54 assert!(!name().is_empty());
55 }
56
57 #[test]
58 fn test_category() {
59 assert!(!category().is_empty());
60 }
61}