Trait fuel_storage::StorageAsRef
source · [−]pub trait StorageAsRef {
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>
where
Type: Mappable,
{ ... }
}
Expand description
Helper trait for StorageInspect
to provide user-friendly API to retrieve storage as reference.
Example
use fuel_storage::{Mappable, StorageInspect, StorageAsRef};
pub struct Contracts;
impl Mappable for Contracts {
type Key = [u8; 32];
type SetValue = [u8];
type GetValue = Vec<u8>;
}
pub struct Balances;
impl Mappable for Balances {
type Key = u128;
type SetValue = u64;
type GetValue = u64;
}
pub trait Logic: StorageInspect<Contracts> + StorageInspect<Balances> {
fn run(&self) {
// You can specify which storage do you want to call with `storage::<Type>()`
let _ = self.storage::<Contracts>().get(&[0; 32]);
let _ = self.storage::<Balances>().get(&123);
}
}
Provided Methods
sourcefn storage<Type>(&self) -> StorageRef<'_, Self, Type>where