#[cfg(feature = "std")]
pub mod system_clock;
#[cfg(feature = "std")]
pub mod thread_local_ctxt;
#[cfg(feature = "rand")]
pub mod rand_rng;
#[cfg(not(feature = "rand"))]
pub type DefaultRng = crate::Empty;
#[cfg(feature = "rand")]
pub type DefaultRng = rand_rng::RandRng;
#[cfg(feature = "std")]
mod std_support {
use super::*;
use emit_core::{clock::ErasedClock, rng::ErasedRng, runtime::AssertInternal};
#[cfg(feature = "std")]
pub type DefaultClock = system_clock::SystemClock;
#[cfg(feature = "std")]
pub type DefaultCtxt = thread_local_ctxt::ThreadLocalCtxt;
pub(crate) struct Platform {
#[cfg(feature = "std")]
pub(crate) clock: AssertInternal<Box<dyn ErasedClock + Send + Sync>>,
#[cfg(feature = "std")]
pub(crate) rng: AssertInternal<Box<dyn ErasedRng + Send + Sync>>,
}
impl Default for Platform {
fn default() -> Self {
Self::new()
}
}
impl Platform {
pub fn new() -> Self {
Platform {
#[cfg(feature = "std")]
clock: AssertInternal(Box::new(DefaultClock::default())),
#[cfg(feature = "std")]
rng: AssertInternal(Box::new(DefaultRng::default())),
}
}
}
}
#[cfg(feature = "std")]
pub use self::std_support::*;
#[cfg(not(feature = "std"))]
mod no_std_support {
#[cfg(not(feature = "std"))]
pub type DefaultClock = crate::Empty;
#[cfg(not(feature = "std"))]
pub type DefaultCtxt = crate::Empty;
}
#[cfg(not(feature = "std"))]
pub use self::no_std_support::*;