use crate::memory::{pool, registry::MemoryRegistryError};
use ic_memory::{DiagnosticExport, MemoryAllocationPool, RuntimeDiagnosticError};
pub const MEMORY_LEDGER_SCHEMA_VERSION: u32 = 1;
pub const MEMORY_PHYSICAL_FORMAT_ID: u32 = 1;
pub struct NativeMemoryLedgerSnapshot {
pub export: DiagnosticExport,
pub allocation_pool: MemoryAllocationPool,
}
pub fn try_snapshot() -> Result<NativeMemoryLedgerSnapshot, MemoryLedgerError> {
Ok(NativeMemoryLedgerSnapshot {
export: ic_memory::default_memory_manager_diagnostic_export()?,
allocation_pool: pool::selected()?,
})
}
#[derive(Debug, thiserror::Error)]
pub enum MemoryLedgerError {
#[error(transparent)]
Diagnostic(#[from] RuntimeDiagnosticError),
#[error(transparent)]
Pool(#[from] MemoryRegistryError),
}