#![forbid(unsafe_code)]
#![deny(rustdoc::broken_intra_doc_links)]
#![doc = include_str!("../README.md")]
pub mod bootstrap;
pub mod declaration;
pub mod diagnostics;
pub mod key;
pub mod ledger;
pub mod physical;
pub mod policy;
pub mod registry;
pub mod runtime;
pub mod schema;
pub mod session;
pub mod slot;
pub mod stable_cell;
pub mod substrate;
pub mod validation;
pub use ic_stable_structures as stable_structures;
pub use bootstrap::{
AllocationBootstrap, BootstrapCommit, BootstrapError, BootstrapReservationError,
BootstrapRetirementError,
};
pub use declaration::{
AllocationDeclaration, DeclarationCollector, DeclarationSnapshot, DeclarationSnapshotError,
};
pub use diagnostics::{DiagnosticExport, DiagnosticGeneration, DiagnosticRecord};
pub use key::{StableKey, StableKeyError};
pub use ledger::{
AllocationHistory, AllocationLedger, AllocationRecord, AllocationReservationError,
AllocationRetirement, AllocationRetirementError, AllocationStageError, AllocationState,
CURRENT_LEDGER_SCHEMA_VERSION, CURRENT_PHYSICAL_FORMAT_ID, GenerationRecord, LedgerCommitError,
LedgerCommitStore, LedgerCompatibilityError, LedgerIntegrityError, LedgerPayloadEnvelope,
LedgerPayloadEnvelopeError, RecoveredLedger, SchemaMetadataRecord,
};
pub use physical::{
AuthoritativeSlot, CommitRecoveryError, CommitSlotDiagnostic, CommitSlotIndex,
CommitStoreDiagnostic, CommittedGenerationBytes, DualCommitStore, DualProtectedCommitStore,
ProtectedGenerationSlot, select_authoritative_slot,
};
pub use policy::AllocationPolicy;
pub use registry::{
StaticMemoryDeclaration, StaticMemoryDeclarationError, StaticMemoryRangeDeclaration,
collect_static_memory_declarations, register_static_memory_declaration,
register_static_memory_manager_declaration,
register_static_memory_manager_declaration_with_schema, register_static_memory_manager_range,
register_static_memory_range_declaration, static_memory_declaration_snapshot,
static_memory_declarations, static_memory_range_authority, static_memory_range_declarations,
};
pub use runtime::{
RuntimeBootstrapError, RuntimeOpenError, RuntimePolicyError, bootstrap_default_memory_manager,
bootstrap_default_memory_manager_with_policy,
};
pub use schema::{SchemaMetadata, SchemaMetadataError};
pub use session::{AllocationSession, AllocationSessionError, ValidatedAllocations};
pub use slot::{
AllocationSlot, AllocationSlotDescriptor, AllocationSlotDescriptorError,
IC_MEMORY_AUTHORITY_OWNER, IC_MEMORY_AUTHORITY_PURPOSE, IC_MEMORY_LEDGER_LABEL,
IC_MEMORY_LEDGER_STABLE_KEY, IC_MEMORY_STABLE_KEY_PREFIX, MEMORY_MANAGER_DESCRIPTOR_VERSION,
MEMORY_MANAGER_GOVERNANCE_MAX_ID, MEMORY_MANAGER_INVALID_ID, MEMORY_MANAGER_LEDGER_ID,
MEMORY_MANAGER_MAX_ID, MEMORY_MANAGER_MIN_ID, MEMORY_MANAGER_SUBSTRATE,
MemoryManagerAuthorityRecord, MemoryManagerIdRange, MemoryManagerRangeAuthority,
MemoryManagerRangeAuthorityError, MemoryManagerRangeError, MemoryManagerRangeMode,
MemoryManagerSlotError, is_ic_memory_stable_key, memory_manager_governance_range,
validate_memory_manager_id,
};
pub use stable_cell::{
STABLE_CELL_HEADER_SIZE, STABLE_CELL_LAYOUT_VERSION, STABLE_CELL_MAGIC,
STABLE_CELL_VALUE_OFFSET, StableCellLedgerError, StableCellLedgerRecord,
StableCellPayloadError, decode_stable_cell_ledger_record, decode_stable_cell_payload,
validate_stable_cell_ledger_memory,
};
pub use substrate::{LedgerAnchor, StorageSubstrate};
pub use validation::{AllocationValidationError, Validate, validate_allocations};
#[doc(hidden)]
pub mod __reexports {
pub use ctor;
}
#[macro_export]
macro_rules! ic_memory_declaration {
(key = $stable_key:literal, ty = $label:path, id = $id:expr $(,)?) => {
const _: () = {
#[allow(dead_code)]
type IcMemoryTypeCheck = $label;
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __ic_memory_register_static_declaration() {
$crate::register_static_memory_manager_declaration(
$id,
env!("CARGO_PKG_NAME"),
stringify!($label),
$stable_key,
)
.expect("ic-memory static memory declaration failed");
}
};
};
(key = $stable_key:literal, label = $label:literal, id = $id:expr $(,)?) => {
const _: () = {
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __ic_memory_register_static_declaration() {
$crate::register_static_memory_manager_declaration(
$id,
env!("CARGO_PKG_NAME"),
$label,
$stable_key,
)
.expect("ic-memory static memory declaration failed");
}
};
};
}
#[macro_export]
macro_rules! ic_memory_range {
(start = $start:expr, end = $end:expr $(,)?) => {
$crate::ic_memory_range!(
start = $start,
end = $end,
mode = Reserved,
);
};
(start = $start:expr, end = $end:expr, mode = $mode:ident $(,)?) => {
const _: () = {
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __ic_memory_register_static_range() {
$crate::register_static_memory_manager_range(
$start,
$end,
env!("CARGO_PKG_NAME"),
$crate::MemoryManagerRangeMode::$mode,
None,
)
.expect("ic-memory static memory range declaration failed");
}
};
};
}
#[macro_export]
macro_rules! ic_memory_key {
($stable_key:literal, $label:path, $id:expr $(,)?) => {{
$crate::ic_memory_declaration!(key = $stable_key, ty = $label, id = $id,);
$crate::runtime::open_default_memory_manager_memory($stable_key, $id)
.expect("ic-memory stable memory opened before runtime bootstrap")
}};
(key = $stable_key:literal, ty = $label:path, id = $id:expr $(,)?) => {{ $crate::ic_memory_key!($stable_key, $label, $id) }};
(key = $stable_key:literal, label = $label:literal, id = $id:expr $(,)?) => {{
$crate::ic_memory_declaration!(key = $stable_key, label = $label, id = $id,);
$crate::runtime::open_default_memory_manager_memory($stable_key, $id)
.expect("ic-memory stable memory opened before runtime bootstrap")
}};
}
#[macro_export]
macro_rules! eager_init {
($body:block) => {
const _: () = {
fn __ic_memory_registered_eager_init_body() {
$body
}
#[ $crate::__reexports::ctor::ctor(unsafe, anonymous, crate_path = $crate::__reexports::ctor) ]
fn __ic_memory_register_eager_init() {
$crate::runtime::defer_eager_init(__ic_memory_registered_eager_init_body);
}
};
};
}