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