Trait gear_common::program_storage::ProgramStorage

source ·
pub trait ProgramStorage {
    type InternalError: Error;
    type Error: From<Self::InternalError> + Debug;
    type BlockNumber: Copy + Saturating;
    type AccountId: Eq + PartialEq;
    type ProgramMap: MapStorage<Key = ProgramId, Value = Program<Self::BlockNumber>>;
    type MemoryPageMap: TripleMapStorage<Key1 = ProgramId, Key2 = MemoryInfix, Key3 = GearPage, Value = PageBuf>;
    type AllocationsMap: MapStorage<Key = ProgramId, Value = IntervalsTree<WasmPage>>;

Show 16 methods // Required method fn pages_final_prefix() -> [u8; 32]; // Provided methods fn reset() { ... } fn add_program( program_id: ProgramId, program: ActiveProgram<Self::BlockNumber>, ) -> Result<(), Self::Error> { ... } fn get_program(program_id: ProgramId) -> Option<Program<Self::BlockNumber>> { ... } fn program_exists(program_id: ProgramId) -> bool { ... } fn update_active_program<F, ReturnType>( program_id: ProgramId, update_action: F, ) -> Result<ReturnType, Self::Error> where F: FnOnce(&mut ActiveProgram<Self::BlockNumber>) -> ReturnType { ... } fn remove_data_for_pages( program_id: ProgramId, memory_infix: MemoryInfix, pages: impl Iterator<Item = GearPage>, ) { ... } fn allocations(program_id: ProgramId) -> Option<IntervalsTree<WasmPage>> { ... } fn set_allocations( program_id: ProgramId, allocations: IntervalsTree<WasmPage>, ) { ... } fn clear_allocations(program_id: ProgramId) { ... } fn memory_infix(program_id: ProgramId) -> Option<MemoryInfix> { ... } fn update_program_if_active<F, ReturnType>( program_id: ProgramId, update_action: F, ) -> Result<ReturnType, Self::Error> where F: FnOnce(&mut Program<Self::BlockNumber>, Self::BlockNumber) -> ReturnType { ... } fn get_program_pages_data( program_id: ProgramId, memory_infix: MemoryInfix, ) -> Result<MemoryMap, Self::Error> { ... } fn set_program_page_data( program_id: ProgramId, memory_infix: MemoryInfix, page: GearPage, page_buf: PageBuf, ) { ... } fn remove_program_page_data( program_id: ProgramId, memory_infix: MemoryInfix, page_num: GearPage, ) { ... } fn clear_program_memory(program_id: ProgramId, memory_infix: MemoryInfix) { ... }
}
Expand description

Trait to work with program data in a storage.

Required Associated Types§

source

type InternalError: Error

source

type Error: From<Self::InternalError> + Debug

source

type BlockNumber: Copy + Saturating

source

type AccountId: Eq + PartialEq

source

type ProgramMap: MapStorage<Key = ProgramId, Value = Program<Self::BlockNumber>>

source

type MemoryPageMap: TripleMapStorage<Key1 = ProgramId, Key2 = MemoryInfix, Key3 = GearPage, Value = PageBuf>

source

type AllocationsMap: MapStorage<Key = ProgramId, Value = IntervalsTree<WasmPage>>

Required Methods§

source

fn pages_final_prefix() -> [u8; 32]

Final full prefix that prefixes all keys of memory pages.

Provided Methods§

source

fn reset()

Attempt to remove all items from all the associated maps.

source

fn add_program( program_id: ProgramId, program: ActiveProgram<Self::BlockNumber>, ) -> Result<(), Self::Error>

Store a program to be associated with the given key program_id from the map.

source

fn get_program(program_id: ProgramId) -> Option<Program<Self::BlockNumber>>

Load the program associated with the given key program_id from the map.

source

fn program_exists(program_id: ProgramId) -> bool

Does the program (explicitly) exist in storage?

source

fn update_active_program<F, ReturnType>( program_id: ProgramId, update_action: F, ) -> Result<ReturnType, Self::Error>
where F: FnOnce(&mut ActiveProgram<Self::BlockNumber>) -> ReturnType,

Update the active program under the given key program_id.

source

fn remove_data_for_pages( program_id: ProgramId, memory_infix: MemoryInfix, pages: impl Iterator<Item = GearPage>, )

source

fn allocations(program_id: ProgramId) -> Option<IntervalsTree<WasmPage>>

source

fn set_allocations(program_id: ProgramId, allocations: IntervalsTree<WasmPage>)

source

fn clear_allocations(program_id: ProgramId)

source

fn memory_infix(program_id: ProgramId) -> Option<MemoryInfix>

source

fn update_program_if_active<F, ReturnType>( program_id: ProgramId, update_action: F, ) -> Result<ReturnType, Self::Error>
where F: FnOnce(&mut Program<Self::BlockNumber>, Self::BlockNumber) -> ReturnType,

Update the program under the given key program_id only if the stored program is an active one.

source

fn get_program_pages_data( program_id: ProgramId, memory_infix: MemoryInfix, ) -> Result<MemoryMap, Self::Error>

Return data buffer for each memory page, which has data.

source

fn set_program_page_data( program_id: ProgramId, memory_infix: MemoryInfix, page: GearPage, page_buf: PageBuf, )

Store a memory page buffer to be associated with the given keys program_id, memory_infix and page from the map.

source

fn remove_program_page_data( program_id: ProgramId, memory_infix: MemoryInfix, page_num: GearPage, )

Remove a memory page buffer under the given keys program_id, memory_infix and page.

source

fn clear_program_memory(program_id: ProgramId, memory_infix: MemoryInfix)

Remove all memory page buffers under the given keys program_id and memory_infix.

Object Safety§

This trait is not object safe.

Implementors§