identity_storage/storage/
mod.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright 2020-2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

//! This module provides a type wrapping a key and key id storage.

mod error;
#[macro_use]
mod jwk_document_ext;
#[cfg(feature = "jpt-bbs-plus")]
mod jwp_document_ext;
mod signature_options;
#[cfg(feature = "jpt-bbs-plus")]
mod timeframe_revocation_ext;

#[cfg(feature = "storage-signer")]
mod storage_signer;
#[cfg(all(test, feature = "memstore"))]
pub(crate) mod tests;

pub use error::*;

pub use jwk_document_ext::*;
#[cfg(feature = "jpt-bbs-plus")]
pub use jwp_document_ext::*;
pub use signature_options::*;
#[cfg(feature = "storage-signer")]
pub use storage_signer::*;
#[cfg(feature = "jpt-bbs-plus")]
pub use timeframe_revocation_ext::*;

/// A type wrapping a key and key id storage, typically used with [`JwkStorage`](crate::key_storage::JwkStorage) and
/// [`KeyIdStorage`](crate::key_id_storage::KeyIdStorage) that should always be used together when calling methods from
/// [`JwkDocumentExt`](crate::storage::JwkDocumentExt).
pub struct Storage<K, I> {
  key_storage: K,
  key_id_storage: I,
}

impl<K, I> Storage<K, I> {
  /// Constructs a new [`Storage`].
  pub fn new(key_storage: K, key_id_storage: I) -> Self {
    Self {
      key_storage,
      key_id_storage,
    }
  }

  /// Obtain a reference to the wrapped [`JwkStorage`](crate::key_storage::JwkStorage).
  pub fn key_storage(&self) -> &K {
    &self.key_storage
  }

  /// Obtain a reference to the wrapped [`KeyIdStorage`](crate::key_id_storage::KeyIdStorage).
  pub fn key_id_storage(&self) -> &I {
    &self.key_id_storage
  }
}