pub trait BorshIntoStorageKey: BorshSerialize { }
Expand description

Converts a Borsh serializable object into a Vec<u8> that is used for a storage key.

use near_sdk::borsh::BorshSerialize;
use near_sdk::BorshIntoStorageKey;
use near_sdk::collections::LookupMap;

#[derive(BorshSerialize)]
 enum StorageKey {
    FungibleToken,
    Metadata { sub_key: String },
}

impl BorshIntoStorageKey for StorageKey {}

let lookup_map_1: LookupMap<u64, String> = LookupMap::new(StorageKey::Metadata { sub_key: String::from("yo") });
let lookup_map_2: LookupMap<String, String> = LookupMap::new(StorageKey::FungibleToken);

Implementors