use std::sync::OnceLock;
use crate::{CoreResult, OxideError};
use super::{OxideChannelError, OxideChannelResult};
static RUNTIME: OnceLock<OxideIsolatedChannelsRuntime> = OnceLock::new();
pub struct OxideIsolatedChannelsRuntime {
_private: (),
}
pub fn init_isolated_channels() -> CoreResult<()> {
let _ = RUNTIME.get_or_init(|| OxideIsolatedChannelsRuntime { _private: () });
Ok(())
}
pub fn isolated_channels_initialized() -> bool {
RUNTIME.get().is_some()
}
pub fn isolated_channels_runtime() -> CoreResult<&'static OxideIsolatedChannelsRuntime> {
RUNTIME.get().ok_or_else(|| OxideError::Internal {
message: "isolated channels runtime not initialized; call init_isolated_channels() first"
.into(),
})
}
pub fn ensure_isolated_channels_initialized() -> OxideChannelResult<()> {
if isolated_channels_initialized() {
Ok(())
} else {
Err(OxideChannelError::Unavailable)
}
}