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