Trait bones_framework::storage::StorageApi

source ·
pub trait StorageApi: Sync + Send {
    // Required methods
    fn save(&mut self, data: Vec<SchemaBox>);
    fn load(&mut self) -> Vec<SchemaBox>;
}
Expand description

Trait implemented by storage backends.

TODO: Implement asynchronous storage API. Currently all storage access is synchronous, which is not good for the user experience when a write to storage could delay the rendering of the next frame. We should come up with a nice-to-use API for asynchronously loading and storing data.

Required Methods§

source

fn save(&mut self, data: Vec<SchemaBox>)

Write the entire collection of objects to storage, replacing the previous storage data. If set, the handler will be called when the data has been written.

source

fn load(&mut self) -> Vec<SchemaBox>

Read the entire collection of objects from storage with handler being called with the data once the load is complete.

Implementors§