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