ic_memory/substrate.rs
1use crate::slot::AllocationSlotDescriptor;
2
3///
4/// LedgerAnchor
5///
6/// Substrate-defined location of the allocation ledger.
7#[derive(Clone, Debug, Eq, PartialEq)]
8pub struct LedgerAnchor {
9 /// Substrate identifier.
10 pub substrate: String,
11 /// Ledger storage descriptor.
12 pub descriptor: AllocationSlotDescriptor,
13}
14
15///
16/// StorageSubstrate
17///
18/// Physical storage provider for the ledger anchor and allocation slots.
19pub trait StorageSubstrate {
20 /// Native slot type accepted by this substrate.
21 type Slot;
22 /// Ledger memory handle.
23 type LedgerMemory;
24 /// Allocation memory handle.
25 type MemoryHandle;
26 /// Substrate error type.
27 type Error;
28
29 /// Open the ledger anchor.
30 fn open_ledger(&self) -> Result<Self::LedgerMemory, Self::Error>;
31
32 /// Open an allocation slot after validation has produced a session.
33 fn open_slot(&self, slot: &AllocationSlotDescriptor)
34 -> Result<Self::MemoryHandle, Self::Error>;
35
36 /// Describe a native slot as a durable allocation slot descriptor.
37 fn describe_slot(&self, slot: &Self::Slot) -> AllocationSlotDescriptor;
38}