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