pub mod anymap;
#[cfg(feature = "std")]
pub mod build_id;
#[cfg(all(
any(feature = "cli", feature = "frida_cli", feature = "qemu_cli"),
feature = "std"
))]
pub mod cli;
#[cfg(feature = "llmp_compression")]
pub mod compress;
#[cfg(feature = "std")]
pub mod core_affinity;
pub mod cpu;
#[cfg(feature = "std")]
pub mod fs;
#[cfg(feature = "std")]
pub mod launcher;
pub mod llmp;
#[cfg(all(feature = "std", unix))]
pub mod minibsod;
pub mod os;
pub mod ownedref;
pub mod rands;
pub mod serdeany;
pub mod shmem;
#[cfg(feature = "std")]
pub mod staterestore;
pub mod tuples;
use alloc::{string::String, vec::Vec};
use core::{iter::Iterator, time};
#[cfg(feature = "std")]
use std::time::{SystemTime, UNIX_EPOCH};
pub trait AsSlice {
type Entry;
fn as_slice(&self) -> &[Self::Entry];
}
pub trait AsMutSlice {
type Entry;
fn as_mut_slice(&mut self) -> &mut [Self::Entry];
}
impl<T> AsSlice for Vec<T> {
type Entry = T;
fn as_slice(&self) -> &[Self::Entry] {
self
}
}
impl<T> AsMutSlice for Vec<T> {
type Entry = T;
fn as_mut_slice(&mut self) -> &mut [Self::Entry] {
self
}
}
impl<T> AsSlice for &[T] {
type Entry = T;
fn as_slice(&self) -> &[Self::Entry] {
self
}
}
impl<T> AsSlice for [T] {
type Entry = T;
fn as_slice(&self) -> &[Self::Entry] {
self
}
}
impl<T> AsMutSlice for &mut [T] {
type Entry = T;
fn as_mut_slice(&mut self) -> &mut [Self::Entry] {
self
}
}
impl<T> AsMutSlice for [T] {
type Entry = T;
fn as_mut_slice(&mut self) -> &mut [Self::Entry] {
self
}
}
pub trait AsIter<'it> {
type Item: 'it;
type IntoIter: Iterator<Item = &'it Self::Item>;
fn as_iter(&'it self) -> Self::IntoIter;
}
pub trait AsIterMut<'it> {
type Item: 'it;
type IntoIter: Iterator<Item = &'it mut Self::Item>;
fn as_iter_mut(&'it mut self) -> Self::IntoIter;
}
pub trait HasLen {
fn len(&self) -> usize;
fn is_empty(&self) -> bool {
self.len() == 0
}
}
pub trait HasRefCnt {
fn refcnt(&self) -> isize;
fn refcnt_mut(&mut self) -> &mut isize;
}
#[cfg(feature = "std")]
#[must_use]
#[inline]
pub fn current_time() -> time::Duration {
SystemTime::now().duration_since(UNIX_EPOCH).unwrap()
}
#[cfg(not(feature = "std"))]
extern "C" {
fn external_current_millis() -> u64;
}
#[cfg(not(feature = "std"))]
#[inline]
#[must_use]
pub fn current_time() -> time::Duration {
let millis = unsafe { external_current_millis() };
time::Duration::from_millis(millis)
}
#[inline]
#[must_use]
pub fn xxh3_rrmxmx_mixer(v: u64) -> u64 {
let tmp = (v >> 32) + ((v & 0xffffffff) << 32);
let bitflip = 0x1cad21f72c81017c ^ 0xdb979082e96dd4de;
let mut h64 = tmp ^ bitflip;
h64 = h64.rotate_left(49) & h64.rotate_left(24);
h64 = h64.wrapping_mul(0x9FB21C651E98DF25);
h64 ^= (h64 >> 35) + 8;
h64 = h64.wrapping_mul(0x9FB21C651E98DF25);
h64 ^= h64 >> 28;
h64
}
#[must_use]
#[inline]
pub fn current_nanos() -> u64 {
current_time().as_nanos() as u64
}
#[must_use]
#[inline]
pub fn current_milliseconds() -> u64 {
current_time().as_millis() as u64
}
#[must_use]
pub fn format_duration_hms(duration: &time::Duration) -> String {
let secs = duration.as_secs();
format!("{}h-{}m-{}s", (secs / 60) / 60, (secs / 60) % 60, secs % 60)
}
#[cfg(feature = "prelude")]
pub mod bolts_prelude {
#[cfg(feature = "std")]
pub use super::build_id::*;
#[cfg(all(
any(feature = "cli", feature = "frida_cli", feature = "qemu_cli"),
feature = "std"
))]
pub use super::cli::*;
#[cfg(feature = "llmp_compression")]
pub use super::compress::*;
#[cfg(feature = "std")]
pub use super::core_affinity::*;
#[cfg(feature = "std")]
pub use super::fs::*;
#[cfg(feature = "std")]
pub use super::launcher::*;
#[cfg(all(feature = "std", unix))]
pub use super::minibsod::*;
#[cfg(feature = "std")]
pub use super::staterestore::*;
pub use super::{
anymap::*, cpu::*, llmp::*, os::*, ownedref::*, rands::*, serdeany::*, shmem::*, tuples::*,
};
}