use sp_allocator::{AllocationStats, FreeingBumpHeapAllocator};
pub struct HostState {
pub(crate) allocator: Option<FreeingBumpHeapAllocator>,
pub(crate) panic_message: Option<String>,
}
impl HostState {
pub(crate) fn new(allocator: FreeingBumpHeapAllocator) -> Self {
Self {
allocator: Some(allocator),
panic_message: None,
}
}
pub(crate) fn take_panic_message(&mut self) -> Option<String> {
self.panic_message.take()
}
pub(crate) fn allocation_stats(&self) -> AllocationStats {
self.allocator
.as_ref()
.expect("allocator is set outside active allocation/deallocation; qed")
.stats()
}
}