Trait StorageAPI

Source
pub trait StorageAPI {
    // Required methods
    fn read(&self, offset: u32, data: &mut [u8]) -> Result<(), HostError>;
    fn write(&self, offset: u32, data: &[u8]) -> Result<(), HostError>;
    fn as_any(&mut self) -> &mut dyn Any;
}
Expand description

the storage APIs that should be provided by the host. It can’t be copied or cloned since it doesn’t have Copy and Clone traits.

Required Methods§

Source

fn read(&self, offset: u32, data: &mut [u8]) -> Result<(), HostError>

This API requests the host to read the slice of data from the storage file at the given offset.

Source

fn write(&self, offset: u32, data: &[u8]) -> Result<(), HostError>

This API requests the host to write the slice of data into the storage file at the given offset

Source

fn as_any(&mut self) -> &mut dyn Any

It is useful for downcasting the trait to the underling struct. For example we can downcast the trait to the mocked object.

Implementors§