diem_secure_storage/
storage.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7use crate::{
8    CryptoStorage, Error, GetResponse, InMemoryStorage, KVStorage,
9    NamespacedStorage, OnDiskStorage, PublicKeyResponse,
10};
11use diem_types::validator_config::{
12    ConsensusPrivateKey, ConsensusPublicKey, ConsensusSignature,
13};
14use enum_dispatch::enum_dispatch;
15use serde::{de::DeserializeOwned, Serialize};
16
17/// This is the Diem interface into secure storage. Any storage engine
18/// implementing this trait should support both key/value operations (e.g., get,
19/// set and create) and cryptographic key operations (e.g., generate_key, sign
20/// and rotate_key).
21
22/// This is a hack that allows us to convert from SecureBackend into a useable
23/// T: Storage. This boilerplate can be 100% generated by a proc macro.
24#[enum_dispatch(KVStorage, CryptoStorage)]
25pub enum Storage {
26    InMemoryStorage(InMemoryStorage),
27    NamespacedStorage(NamespacedStorage),
28    OnDiskStorage(OnDiskStorage),
29}