pub trait ProgramStorage {
    type InternalError: Error;
    type Error: From<Self::InternalError> + Debug;
    type BlockNumber: Copy + Saturating;
    type ProgramMap: MapStorage<Key = ProgramId, Value = Program<Self::BlockNumber>>;
    type MemoryPageMap: DoubleMapStorage<Key1 = ProgramId, Key2 = GearPage, Value = PageBuf>;
    type WaitingInitMap: AppendMapStorage<MessageId, ProgramId, Vec<MessageId>>;

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 remove_active_program( program_id: ProgramId ) -> Result<(ActiveProgram<Self::BlockNumber>, MemoryMap), 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 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_data_for_pages<'a>( program_id: ProgramId, pages: impl Iterator<Item = &'a GearPage> ) -> Result<MemoryMap, Self::Error> { ... } fn set_program_page_data( program_id: ProgramId, page: GearPage, page_buf: PageBuf ) { ... } fn remove_program_page_data(program_id: ProgramId, page_num: GearPage) { ... } fn remove_program_pages(program_id: ProgramId) { ... } fn waiting_init_get_messages(program_id: ProgramId) -> Vec<MessageId> { ... } fn waiting_init_take_messages(program_id: ProgramId) -> Vec<MessageId> { ... } fn waiting_init_append_message_id( dest_prog_id: ProgramId, message_id: MessageId ) { ... } fn waiting_init_remove(program_id: ProgramId) { ... }
}
Expand description

Trait to work with program data in a storage.

Required Associated Types§

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 remove_active_program( program_id: ProgramId ) -> Result<(ActiveProgram<Self::BlockNumber>, MemoryMap), Self::Error>

Remove an active program 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 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_data_for_pages<'a>( program_id: ProgramId, pages: impl Iterator<Item = &'a GearPage> ) -> Result<MemoryMap, Self::Error>

Return program data for each page from pages.

source

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

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

source

fn remove_program_page_data(program_id: ProgramId, page_num: GearPage)

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

source

fn remove_program_pages(program_id: ProgramId)

Remove all memory page buffers under the given key program_id.

source

fn waiting_init_get_messages(program_id: ProgramId) -> Vec<MessageId>

Load the messages to uninitialized program associated with the given key program_id from the map.

source

fn waiting_init_take_messages(program_id: ProgramId) -> Vec<MessageId>

Take the messages to uninitialized program under the given key program_id.

source

fn waiting_init_append_message_id( dest_prog_id: ProgramId, message_id: MessageId )

Append the given message id to the list of messages to uninitialized program in the storage.

source

fn waiting_init_remove(program_id: ProgramId)

Remove all messages to uninitialized program under the given key program_id.

Implementors§