StorageValue- StorageMap

/// Get the storage key.
fn key() -> &'static [u8];

/// true if the value is defined in storage.
fn exists(storage: &S) -> bool {
storage.exists(Self::key())
}

/// Load the value from the provided storage instance.
fn get(storage: &S) -> Self::Query;

/// Take a value from storage, removing it afterwards.
fn take(storage: &S) -> Self::Query;

/// Store a value under this key into the provided storage instance.
fn put(val: &T, storage: &S) {
storage.put(Self::key(), val)
}

/// Mutate this value
fn mutate R, S: Storage>(f: F, storage: &S) -> R;

/// Clear the storage value.
fn kill(storage: &S) {
storage.kill(Self::key())
}

/// Get the prefix key in storage.
fn prefix() -> &'static [u8];

/// Get the storage key used to fetch a value corresponding to a specific key.
fn key_for(x: &K) -> Vec;

/// true if the value is defined in storage.
fn exists(key: &K, storage: &S) -> bool {
storage.exists(&Self::key_for(key)[..])
}

/// Load the value associated with the given key from the map.
fn get(key: &K, storage: &S) -> Self::Query;

/// Take the value under a key.
fn take(key: &K, storage: &S) -> Self::Query;

/// Store a value to be associated with the given key from the map.
fn insert(key: &K, val: &V, storage: &S) {
storage.put(&Self::key_for(key)[..], val);
}

/// Remove the value under a key.
fn remove(key: &K, storage: &S) {
storage.kill(&Self::key_for(key)[..]);
}

/// Mutate the value under a key.
fn mutate R, S: Storage>(key: &K, f: F, storage: &S) -> R;

你可能感兴趣的:(StorageValue- StorageMap)