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§
Sourcefn read(&self, offset: u32, data: &mut [u8]) -> Result<(), HostError>
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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".