pub struct Namespaced<S> { /* private fields */ }
Expand description

This provides a light wrapper around KV storages to support a namespace. That namespace is effectively prefixing all keys with then namespace value and “/” so a namespace of foo and a key of bar becomes “foo/bar”. Without a namespace, the key would just be “bar”.

Implementations§

source§

impl<S> Namespaced<S>

source

pub fn new<N: Into<String>>(namespace: N, inner: S) -> Self

source

pub fn inner(&self) -> &S

source

pub fn inner_mut(&mut self) -> &mut S

source

pub fn into_inner(self) -> S

source

pub fn namespace(&self) -> &str

source§

impl<'a, S> Namespaced<&'a S>where S: KVStorage,

source

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

This is a small hack in order to allow for calling KVStorage::get from a Namespaced created from an &S and not an S

Trait Implementations§

source§

impl<S: CryptoStorage> CryptoStorage for Namespaced<S>

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 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<S: KVStorage> KVStorage for Namespaced<S>

source§

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

Note: This is not a namespace function

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§

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.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Namespaced<S>where S: RefUnwindSafe,

§

impl<S> Send for Namespaced<S>where S: Send,

§

impl<S> Sync for Namespaced<S>where S: Sync,

§

impl<S> Unpin for Namespaced<S>where S: Unpin,

§

impl<S> UnwindSafe for Namespaced<S>where S: UnwindSafe,

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