pub struct MemoryRuntime<M: Memory> { /* private fields */ }Expand description
MemoryRuntime
Canonical owner of allocation bootstrap state for one backing memory.
The runtime owns its MemoryManager, allocation-ledger cell, bootstrap
lifecycle, committed allocation capability, opens, and diagnostics. Static
linked-program declarations are supplied separately as one immutable
SealedDeclarationSnapshot.
M needs only Memory. The runtime does not require the backing memory
to be Send, Sync, Clone, or 'static.
Implementations§
Source§impl<M: Memory> MemoryRuntime<M>
impl<M: Memory> MemoryRuntime<M>
Sourcepub fn diagnostic_export(
&self,
) -> Result<DiagnosticExport, RuntimeDiagnosticError>
pub fn diagnostic_export( &self, ) -> Result<DiagnosticExport, RuntimeDiagnosticError>
Export this runtime’s recovered ledger and live virtual-memory sizes.
Sourcepub fn commit_recovery_diagnostic(
&self,
) -> Result<CommitStoreDiagnostic, RuntimeDiagnosticError>
pub fn commit_recovery_diagnostic( &self, ) -> Result<CommitStoreDiagnostic, RuntimeDiagnosticError>
Diagnose protected commit recovery from this runtime’s ledger memory.
This operation is available before bootstrap when the stable-cell envelope is readable or the ledger memory is empty.
Sourcepub fn doctor_report(
&self,
declarations: &SealedDeclarationSnapshot,
) -> MemoryRuntimeDoctorReport
pub fn doctor_report( &self, declarations: &SealedDeclarationSnapshot, ) -> MemoryRuntimeDoctorReport
Build preflight and lifecycle diagnostics for this runtime.
Source§impl<M: Memory> MemoryRuntime<M>
impl<M: Memory> MemoryRuntime<M>
Sourcepub fn new(memory: M) -> Result<Self, RuntimeConstructionError>
pub fn new(memory: M) -> Result<Self, RuntimeConstructionError>
Construct an unbootstrapped runtime without overwriting foreign memory.
Empty backing memory is initialized as an
ic_stable_structures::MemoryManager. Nonempty memory must already
contain the current MemoryManager magic and layout version; otherwise
construction returns a typed error before MemoryManager::init can
write its header or allocation table. A pre-grown blank memory is
nonempty and is therefore rejected rather than assumed disposable.
§Errors
Returns RuntimeConstructionError::ForeignMemory for nonempty memory
without MemoryManager magic, or
RuntimeConstructionError::UnsupportedMemoryManagerVersion when the
magic is recognized but the layout version is not current.
Sourcepub const fn is_bootstrapped(&self) -> bool
pub const fn is_bootstrapped(&self) -> bool
Return whether this runtime has published committed allocation authority.
Sourcepub fn bootstrap<P: RuntimeBootstrapPolicy>(
&mut self,
declarations: &SealedDeclarationSnapshot,
policy: &P,
) -> Result<&CommittedAllocations, RuntimeBootstrapError<P::Error>>
pub fn bootstrap<P: RuntimeBootstrapPolicy>( &mut self, declarations: &SealedDeclarationSnapshot, policy: &P, ) -> Result<&CommittedAllocations, RuntimeBootstrapError<P::Error>>
Bootstrap this backing memory from one immutable declaration snapshot.
Recovery, policy evaluation, staging, persistence, and capability
publication are local to this runtime. A repeated call is idempotent
only when the sealed declaration snapshot and
RuntimeBootstrapPolicy::runtime_bootstrap_identity match the
successful bootstrap. A mismatch returns a typed error without
advancing the durable generation or re-evaluating policy.
Sourcepub const fn committed_allocations(
&self,
) -> Result<&CommittedAllocations, RuntimeOpenError>
pub const fn committed_allocations( &self, ) -> Result<&CommittedAllocations, RuntimeOpenError>
Borrow this runtime’s committed allocation-open capability.
Sourcepub fn open_memory(
&self,
stable_key: &str,
expected_id: u8,
) -> Result<VirtualMemory<M>, RuntimeOpenError>
pub fn open_memory( &self, stable_key: &str, expected_id: u8, ) -> Result<VirtualMemory<M>, RuntimeOpenError>
Open this runtime’s committed memory by stable key and expected ID.