Transactional storage for Tezos Smart Rollup kernels.

This crate supports dealing with objects for updating storage. All objects are stored in durable storage.

To use this crate, provide a definition of an object. The object structure should follow these guidelines:

NB an object must only look in durable storage prefixed by its OwnedPath.

To use this crate, create the wanted value struct and storage object like so:

``` use tezossmartrolluphost::runtime::Runtime; use tezossmartrolluphost::path::{concat, RefPath, OwnedPath}; use tezossmartrollupstorage::storage::Storage; use tezossmartrollupmock::MockHost;

struct MyValue { path: OwnedPath, }

const VALUEPATH: RefPath = RefPath::assertfrom(b"/value");

impl MyValue { pub fn setter(&mut self, host: &mut impl Runtime, v: &str) { let valuepath = concat(&self.path, &VALUEPATH) .expect("Could not get path for value"); host.storewrite(&valuepath, v.as_bytes(), 0) .expect("Could not set value"); }

pub fn getter( &mut self, host: &impl Runtime, ) -> Vec { let valuepath = concat(&self.path, &VALUEPATH) .expect("Could not get path for value"); host.storeread(&valuepath, 0, 1024) .expect("Could not read value") } }

impl From for MyValue { fn from(path: OwnedPath) -> Self { Self { path } } }

const VALUESPATH: RefPath = RefPath::assertfrom(b"/values");

let mut host = MockHost::default();

let mut storage = Storage::::init(&VALUES_PATH) .expect("Could not create storage interface");

storage.begin_transaction(&mut host) .expect("Could not begin transaction");

let valueid = RefPath::assertfrom(b"/my.value.id");

let mut value = storage.createnew(&mut host, &valueid) .expect("Could not create new value") .expect("Value already exists");

value.setter(&mut host, "some value");

storage.commit_transaction(&mut host) .expect("Could not commit transaction"); ```