| 280 | } |
| 281 | |
| 282 | fn new_standard_machine_id() -> String { |
| 283 | // Template: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx |
| 284 | // y is one of 8, 9, a, b |
| 285 | let mut rng = thread_rng(); |
| 286 | let mut id = String::with_capacity(36); |
| 287 | for (i, char_template) in "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".chars().enumerate() { |
| 288 | if char_template == '-' || char_template == '4' { |
| 289 | id.push(char_template); |
| 290 | } else if char_template == 'x' { |
| 291 | id.push_str(&format!("{:x}", rng.gen_range(0..16))); |
| 292 | } else if char_template == 'y' { |
| 293 | id.push_str(&format!("{:x}", rng.gen_range(8..12))); // 8, 9, a, b |
| 294 | } |
| 295 | } |
| 296 | id |
| 297 | } |
| 298 | |
| 299 | #[derive(Deserialize)] |
| 300 | struct PackageJson { |