identity_storage/storage/
mod.rs

1// Copyright 2020-2023 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4//! This module provides a type wrapping a key and key id storage.
5
6mod error;
7#[macro_use]
8mod jwk_document_ext;
9#[cfg(feature = "jpt-bbs-plus")]
10mod jwp_document_ext;
11mod signature_options;
12#[cfg(feature = "jpt-bbs-plus")]
13mod timeframe_revocation_ext;
14
15#[cfg(all(test, feature = "memstore"))]
16pub(crate) mod tests;
17
18pub use error::*;
19
20pub use jwk_document_ext::*;
21#[cfg(feature = "jpt-bbs-plus")]
22pub use jwp_document_ext::*;
23pub use signature_options::*;
24#[cfg(feature = "jpt-bbs-plus")]
25pub use timeframe_revocation_ext::*;
26
27/// A type wrapping a key and key id storage, typically used with [`JwkStorage`](crate::key_storage::JwkStorage) and
28/// [`KeyIdStorage`](crate::key_id_storage::KeyIdStorage) that should always be used together when calling methods from
29/// [`JwkDocumentExt`](crate::storage::JwkDocumentExt).
30pub struct Storage<K, I> {
31  key_storage: K,
32  key_id_storage: I,
33}
34
35impl<K, I> Storage<K, I> {
36  /// Constructs a new [`Storage`].
37  pub fn new(key_storage: K, key_id_storage: I) -> Self {
38    Self {
39      key_storage,
40      key_id_storage,
41    }
42  }
43
44  /// Obtain a reference to the wrapped [`JwkStorage`](crate::key_storage::JwkStorage).
45  pub fn key_storage(&self) -> &K {
46    &self.key_storage
47  }
48
49  /// Obtain a reference to the wrapped [`KeyIdStorage`](crate::key_id_storage::KeyIdStorage).
50  pub fn key_id_storage(&self) -> &I {
51    &self.key_id_storage
52  }
53}