#![deny(unsafe_code, unsafe_op_in_unsafe_fn)]
#![deny(rustdoc::broken_intra_doc_links)]
#![doc = include_str!("../README.md")]
mod allocation_pool;
mod bounded_writer;
mod capability;
mod cbor;
mod constants;
mod declaration;
mod diagnostics;
mod hash;
mod key;
mod ledger;
mod physical;
mod policy;
mod requests;
mod runtime;
mod schema;
mod slot;
mod sort;
mod stable_cell;
mod text;
mod validation;
#[cfg(test)]
mod test_cbor {
use serde::{Serialize, de::DeserializeOwned};
pub use ciborium::Value;
pub fn to_vec<T: Serialize>(
value: &T,
) -> Result<Vec<u8>, ciborium::ser::Error<std::io::Error>> {
let mut bytes = Vec::new();
ciborium::into_writer(value, &mut bytes)?;
Ok(bytes)
}
pub fn from_slice<T: DeserializeOwned>(
bytes: &[u8],
) -> Result<T, ciborium::de::Error<std::io::Error>> {
crate::cbor::from_slice_exact(bytes)
}
pub fn to_value<T: Serialize>(value: T) -> Result<Value, ciborium::value::Error> {
Value::serialized(&value)
}
pub fn hex_fixture(contents: &str) -> Vec<u8> {
let hex = contents
.chars()
.filter(|char| !char.is_whitespace())
.collect::<String>();
assert_eq!(hex.len() % 2, 0, "fixture hex must have byte pairs");
hex.as_bytes()
.as_chunks::<2>()
.0
.iter()
.map(|pair| {
let pair = std::str::from_utf8(pair).expect("fixture hex is utf8");
u8::from_str_radix(pair, 16).expect("fixture hex byte")
})
.collect()
}
}
pub use ic_stable_structures;
pub use allocation_pool::{MemoryAllocationPool, MemoryAllocationPoolError, MemoryAuthority};
pub use capability::CommittedAllocations;
pub use constants::{
MAX_LEDGER_BYTES, MAX_LEDGER_NESTING, MAX_LEDGER_RECORD_BYTES, WASM_PAGE_SIZE_BYTES,
};
pub use declaration::{AllocationDeclaration, DeclarationSnapshotError};
pub use diagnostics::{
DiagnosticCheck, DiagnosticCode, DiagnosticExport, DiagnosticFailure, DiagnosticMemorySize,
DiagnosticRecord, DiagnosticRuntimeBinding, DiagnosticStableCell, DiagnosticStableCellStatus,
MemoryRuntimeDoctorReport,
};
pub use key::{StableKey, StableKeyError};
pub use ledger::LedgerCommitStore;
pub use ledger::{
AllocationLedger, AllocationRecord, AllocationStageError, AllocationState, LedgerCommitError,
LedgerIntegrityError, RecoveredLedger,
};
pub use physical::{CommitRecoveryError, CommitSnapshotDiagnostic};
pub use policy::{PolicyIdentity, PolicyIdentityError, RuntimeBootstrapPolicy};
pub use requests::{MemoryDeclarationError, MemoryRequest, SealedDeclarationSnapshot};
pub use runtime::{
AllocationBinding, BootstrapAdmission, BootstrapAdmissionError, GenericAllocationPolicy,
MemoryAllocation, MemoryAllocationSummary, MemoryAllocations, MemoryBindingSummary,
MemoryManagerConfig, MemoryManagerLayoutError, MemoryResolutionError, MemoryRuntime,
RuntimeAdoptionError, RuntimeBootstrapError, RuntimeConstructionError, RuntimeDiagnosticError,
RuntimeGrowError, RuntimeMemory, RuntimeOpenError,
};
pub use schema::{SchemaMetadata, SchemaMetadataError};
pub use slot::{
IC_MEMORY_AUTHORITY_OWNER, IC_MEMORY_LEDGER_STABLE_KEY, IC_MEMORY_STABLE_KEY_PREFIX,
MEMORY_MANAGER_GOVERNANCE_MAX_ID, MEMORY_MANAGER_INVALID_ID, MEMORY_MANAGER_LEDGER_ID,
MEMORY_MANAGER_MAX_ID, MEMORY_MANAGER_MIN_ID, MemoryManagerIdRange, MemoryManagerRangeError,
MemoryManagerSlot, 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, StableCellPayloadError,
decode_stable_cell_commit_store, decode_stable_cell_commit_store_from_memory,
decode_stable_cell_payload,
};
pub use validation::AllocationValidationError;
#[cfg(test)]
mod allocation_measurements_tests;
#[cfg(any(test, feature = "test-support"))]
pub mod testing;