defuse_near_utils/
prefix.rs1use near_sdk::{BorshStorageKey, IntoStorageKey, borsh::BorshSerialize};
2
3pub trait NestPrefix: Sized + IntoStorageKey {
4 fn nest<S>(self, nested: S) -> NestedPrefix<Self, S>
5 where
6 S: BorshSerialize,
7 {
8 NestedPrefix {
9 parent: self,
10 nested,
11 }
12 }
13}
14impl<T> NestPrefix for T where T: IntoStorageKey {}
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, BorshSerialize, BorshStorageKey)]
17#[borsh(crate = "::near_sdk::borsh")]
18pub struct NestedPrefix<S, P> {
19 parent: S,
20 nested: P,
21}