Skip to main content

tezos_smart_rollup_storage/
lib.rs

1// SPDX-FileCopyrightText: 2022-2023 TriliTech <contact@trili.tech>
2//
3// SPDX-License-Identifier: MIT
4
5#![doc = include_str!("../README.md")]
6
7extern crate tezos_smart_rollup_debug as debug;
8extern crate tezos_smart_rollup_host as host;
9
10use thiserror::Error;
11
12/// Account transaction errors
13///
14/// All errors that may occur when using the accoun transaction API. When
15/// the error variant encapsulates some other error type, this is where the
16/// error originates from the durable storage interface on the host runtime.
17#[derive(Error, Copy, Eq, PartialEq, Clone, Debug)]
18pub enum StorageError {
19    /// Invalid accounts path. Could not get the string representation of
20    /// the accounts storage path.
21    #[error("Invalid accounts storage path")]
22    InvalidAccountsPath,
23    /// Some path in durable storage was already in use when the storage
24    /// interface needed to use it for holding a transaction.
25    #[error("Transaction storage is already in use")]
26    StorageInUse,
27    /// Some storage operation was tried, but the storage doesn't even have
28    /// the base (original) layer of accounts available.
29    #[error("No storage")]
30    NoStorage,
31    /// Some transaction operation, commit or rollback, was attempted while
32    /// no transaction was in progress.
33    #[error("No current transaction to commit or roll back")]
34    NoCurrentTransaction,
35    /// Tried to create an invalid path to accounts. Check that the path to
36    /// the storage for original account values (the base layer) starts with
37    /// a '/' character (it should).
38    #[error("Path error")]
39    PathError(host::path::PathError),
40    /// Some error was encountered while using the durable storage. This may
41    /// happen when doing some transaction operation.
42    #[error("Runtrime error")]
43    RuntimeError(host::runtime::RuntimeError),
44}
45
46impl From<host::path::PathError> for StorageError {
47    fn from(path_error: host::path::PathError) -> Self {
48        StorageError::PathError(path_error)
49    }
50}
51
52impl From<host::runtime::RuntimeError> for StorageError {
53    fn from(runtime_error: host::runtime::RuntimeError) -> Self {
54        StorageError::RuntimeError(runtime_error)
55    }
56}
57
58mod layer;
59pub mod storage;