pub enum Storage {
    GitHubStorage(GitHubStorage),
    VaultStorage(VaultStorage),
    InMemoryStorage(InMemoryStorage),
    NamespacedStorage(Namespaced<Box<Storage>>),
    OnDiskStorage(OnDiskStorage),
}
Expand description

This is the Diem interface into secure storage. Any storage engine implementing this trait should support both key/value operations (e.g., get, set and create) and cryptographic key operations (e.g., generate_key, sign and rotate_key). This is a hack that allows us to convert from SecureBackend into a useable T: Storage. This boilerplate can be 100% generated by a proc macro.

Variants§

§

GitHubStorage(GitHubStorage)

§

VaultStorage(VaultStorage)

§

InMemoryStorage(InMemoryStorage)

§

NamespacedStorage(Namespaced<Box<Storage>>)

§

OnDiskStorage(OnDiskStorage)

Trait Implementations§

source§

impl CryptoStorage for Box<Storage>

source§

fn create_key(&mut self, name: &str) -> Result<Ed25519PublicKey, Error>

Securely generates a new named Ed25519 private key. The behavior for calling this interface multiple times with the same name is implementation specific.
source§

fn export_private_key(&self, name: &str) -> Result<Ed25519PrivateKey, Error>

Returns the Ed25519 private key stored at ‘name’.
source§

fn import_private_key( &mut self, name: &str, key: Ed25519PrivateKey ) -> Result<(), Error>

An optional API that allows importing private keys and storing them at the provided name. This is not intended to be used in production and the API may throw unimplemented if not used correctly. As this is purely a testing API, there is no defined behavior for importing a key for a given name if that name already exists. It only exists to allow Diem to be run in test environments where a set of deterministic keys must be generated.
source§

fn export_private_key_for_version( &self, name: &str, version: Ed25519PublicKey ) -> Result<Ed25519PrivateKey, Error>

Returns the Ed25519 private key stored at ‘name’ and identified by ‘version’, which is the corresponding public key. This may fail even if the ‘named’ key exists but the version is not present.
source§

fn get_public_key(&self, name: &str) -> Result<PublicKeyResponse, Error>

Returns the Ed25519 public key stored at ‘name’.
source§

fn get_public_key_previous_version( &self, name: &str ) -> Result<Ed25519PublicKey, Error>

Returns the previous version of the Ed25519 public key stored at ‘name’. For the most recent version, see ‘get_public_key(..)’ above.
source§

fn rotate_key(&mut self, name: &str) -> Result<Ed25519PublicKey, Error>

Rotates an Ed25519 private key. Future calls without version to this ‘named’ key will return the rotated key instance. The previous key is retained and can be accessed via the version. At most two versions are expected to be retained.
source§

fn sign<T: CryptoHash + Serialize>( &self, name: &str, message: &T ) -> Result<Ed25519Signature, Error>

Signs the provided securely-hashable struct, using the ‘named’ private key.
source§

fn sign_using_version<T: CryptoHash + Serialize>( &self, name: &str, version: Ed25519PublicKey, message: &T ) -> Result<Ed25519Signature, Error>

Signs the provided securely-hashable struct, using the ‘named’ and ‘versioned’ private key. This may fail even if the ‘named’ key exists but the version is not present.
source§

impl CryptoStorage for Storage

source§

fn create_key( &mut self, __enum_dispatch_arg_0: &str ) -> Result<Ed25519PublicKey, Error>

Securely generates a new named Ed25519 private key. The behavior for calling this interface multiple times with the same name is implementation specific.

source§

fn export_private_key( &self, __enum_dispatch_arg_0: &str ) -> Result<Ed25519PrivateKey, Error>

Returns the Ed25519 private key stored at ‘name’.

source§

fn import_private_key( &mut self, __enum_dispatch_arg_0: &str, __enum_dispatch_arg_1: Ed25519PrivateKey ) -> Result<(), Error>

An optional API that allows importing private keys and storing them at the provided name. This is not intended to be used in production and the API may throw unimplemented if not used correctly. As this is purely a testing API, there is no defined behavior for importing a key for a given name if that name already exists. It only exists to allow Diem to be run in test environments where a set of deterministic keys must be generated.

source§

fn export_private_key_for_version( &self, __enum_dispatch_arg_0: &str, __enum_dispatch_arg_1: Ed25519PublicKey ) -> Result<Ed25519PrivateKey, Error>

Returns the Ed25519 private key stored at ‘name’ and identified by ‘version’, which is the corresponding public key. This may fail even if the ‘named’ key exists but the version is not present.

source§

fn get_public_key( &self, __enum_dispatch_arg_0: &str ) -> Result<PublicKeyResponse, Error>

Returns the Ed25519 public key stored at ‘name’.

source§

fn get_public_key_previous_version( &self, __enum_dispatch_arg_0: &str ) -> Result<Ed25519PublicKey, Error>

Returns the previous version of the Ed25519 public key stored at ‘name’. For the most recent version, see ‘get_public_key(..)’ above.

source§

fn rotate_key( &mut self, __enum_dispatch_arg_0: &str ) -> Result<Ed25519PublicKey, Error>

Rotates an Ed25519 private key. Future calls without version to this ‘named’ key will return the rotated key instance. The previous key is retained and can be accessed via the version. At most two versions are expected to be retained.

source§

fn sign<T: CryptoHash + Serialize>( &self, __enum_dispatch_arg_0: &str, __enum_dispatch_arg_1: &T ) -> Result<Ed25519Signature, Error>

Signs the provided securely-hashable struct, using the ‘named’ private key.

source§

fn sign_using_version<T: CryptoHash + Serialize>( &self, __enum_dispatch_arg_0: &str, __enum_dispatch_arg_1: Ed25519PublicKey, __enum_dispatch_arg_2: &T ) -> Result<Ed25519Signature, Error>

Signs the provided securely-hashable struct, using the ‘named’ and ‘versioned’ private key. This may fail even if the ‘named’ key exists but the version is not present.

source§

impl From<GitHubStorage> for Storage

source§

fn from(v: GitHubStorage) -> Storage

Converts to this type from the input type.
source§

impl From<InMemoryStorage> for Storage

source§

fn from(v: InMemoryStorage) -> Storage

Converts to this type from the input type.
source§

impl From<Namespaced<Box<Storage, Global>>> for Storage

source§

fn from(v: Namespaced<Box<Storage>>) -> Storage

Converts to this type from the input type.
source§

impl From<OnDiskStorage> for Storage

source§

fn from(v: OnDiskStorage) -> Storage

Converts to this type from the input type.
source§

impl From<VaultStorage> for Storage

source§

fn from(v: VaultStorage) -> Storage

Converts to this type from the input type.
source§

impl KVStorage for Box<Storage>

source§

fn available(&self) -> Result<(), Error>

Returns an error if the backend service is not online and available.
source§

fn get<T: DeserializeOwned>(&self, key: &str) -> Result<GetResponse<T>, Error>

Retrieves a value from storage and fails if the backend is unavailable or the process has invalid permissions.
source§

fn set<T: Serialize>(&mut self, key: &str, value: T) -> Result<(), Error>

Sets a value in storage and fails if the backend is unavailable or the process has invalid permissions.
source§

fn reset_and_clear(&mut self) -> Result<(), Error>

Resets and clears all data held in the storage engine. Note: this should only be exposed and used for testing. Resetting the storage engine is not something that should be supported in production.
source§

impl KVStorage for Storage

source§

fn available(&self) -> Result<(), Error>

Returns an error if the backend service is not online and available.

source§

fn get<T: DeserializeOwned>( &self, __enum_dispatch_arg_0: &str ) -> Result<GetResponse<T>, Error>

Retrieves a value from storage and fails if the backend is unavailable or the process has invalid permissions.

source§

fn set<T: Serialize>( &mut self, __enum_dispatch_arg_0: &str, __enum_dispatch_arg_1: T ) -> Result<(), Error>

Sets a value in storage and fails if the backend is unavailable or the process has invalid permissions.

source§

fn reset_and_clear(&mut self) -> Result<(), Error>

Resets and clears all data held in the storage engine. Note: this should only be exposed and used for testing. Resetting the storage engine is not something that should be supported in production.

source§

impl TryInto<GitHubStorage> for Storage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into( self ) -> Result<GitHubStorage, <Self as TryInto<GitHubStorage>>::Error>

Performs the conversion.
source§

impl TryInto<InMemoryStorage> for Storage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into( self ) -> Result<InMemoryStorage, <Self as TryInto<InMemoryStorage>>::Error>

Performs the conversion.
source§

impl TryInto<Namespaced<Box<Storage, Global>>> for Storage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into( self ) -> Result<Namespaced<Box<Storage>>, <Self as TryInto<Namespaced<Box<Storage>>>>::Error>

Performs the conversion.
source§

impl TryInto<OnDiskStorage> for Storage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into( self ) -> Result<OnDiskStorage, <Self as TryInto<OnDiskStorage>>::Error>

Performs the conversion.
source§

impl TryInto<VaultStorage> for Storage

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_into( self ) -> Result<VaultStorage, <Self as TryInto<VaultStorage>>::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more