//! # 🔩 Core API
//!
//! This is the core layer of the Ark API and is always available for all modules.
//! Most of the functionality in here is internal for the API crate, and shouldn't be needed by users.
//!
//! The primary usage of it is for logging and returning data back to the host
use crate::ffi;
pub use ffi::core_v3::LogLevel;
mod debug_context_property;
pub use debug_context_property::*;
/// Return a slice from a Wasm function
pub fn return_slice<T: Copy>(values: &[T]) -> u32 {
unsafe {
ffi::core_v0::core__return_slice(
values.as_ptr().cast::<u8>(),
values.len() as u32,
(values.len() * std::mem::size_of::<T>()) as u32,
)
}
}
/// Log a string with the specified log level
pub fn log(level: LogLevel, s: &str) {
unsafe {
let error_code = ffi::core_v3::core__log(level, s.as_ptr(), s.len() as u32);
assert!(error_code == crate::ErrorCode::Success);
}
}