1pub mod binproxy;
4pub mod clone;
5pub mod constraint;
6pub mod content_hash;
7pub mod dirs;
8pub mod error;
9pub mod extract;
10pub mod fetch;
11pub mod glob;
12pub mod installer;
13pub mod installers;
14pub mod jsonfile;
15pub mod layout;
16pub mod lock;
17pub mod path_install;
18pub mod pathutil;
19pub mod pest_plugin;
20pub mod phparray;
21pub mod phpcs_installer;
22pub mod phpjson;
23pub mod phpserialize;
24pub mod platform;
25pub mod root_version;
26pub mod runtime_stub;
27pub mod scope;
28pub mod state;
29pub mod store;
30pub mod version;
31
32pub use error::{Error, Result};
33
34pub fn random_bytes(n: usize) -> Vec<u8> {
37 let mut out = vec![0u8; n];
38 #[cfg(unix)]
39 {
40 use std::io::Read as _;
41 if let Ok(mut f) = std::fs::File::open("/dev/urandom") {
42 if f.read_exact(&mut out).is_ok() {
43 return out;
44 }
45 }
46 }
47 use std::hash::{BuildHasher as _, Hasher as _};
48 let mut i = 0;
49 while i < n {
50 let word = std::collections::hash_map::RandomState::new()
51 .build_hasher()
52 .finish();
53 for b in word.to_le_bytes() {
54 if i < n {
55 out[i] = b;
56 i += 1;
57 }
58 }
59 }
60 out
61}