unc_sdk/utils/
storage_key_impl.rs

1/// Converts Self into a [`Vec<u8>`] that is used for a storage key through [`into_storage_key`].
2///
3/// [`into_storage_key`]: IntoStorageKey::into_storage_key
4pub trait IntoStorageKey {
5    /// Consumes self and returns [`Vec<u8>`] bytes which are used as a storage key.
6    fn into_storage_key(self) -> Vec<u8>;
7}
8
9impl IntoStorageKey for Vec<u8> {
10    #[inline]
11    fn into_storage_key(self) -> Vec<u8> {
12        self
13    }
14}
15
16impl<'a> IntoStorageKey for &'a [u8] {
17    #[inline]
18    fn into_storage_key(self) -> Vec<u8> {
19        self.to_vec()
20    }
21}
22
23impl<'a> IntoStorageKey for &'a [u8; 1] {
24    #[inline]
25    fn into_storage_key(self) -> Vec<u8> {
26        self.to_vec()
27    }
28}
29
30impl IntoStorageKey for u8 {
31    #[inline]
32    fn into_storage_key(self) -> Vec<u8> {
33        vec![self]
34    }
35}