[][src]Struct substrate_frame_rpc_support::StorageQuery

pub struct StorageQuery<V> { /* fields omitted */ }

A typed query on chain state usable from an RPC client.

pub type Loc = (i64, i64, i64);
pub type Block = u8;

// Note that all fields are marked pub.
decl_storage! {
    trait Store for Module<T: Trait> as TestRuntime {
        pub LastActionId: u64;
        pub Voxels: map hasher(blake2_128_concat) Loc => Block;
        pub Actions: map hasher(blake2_128_concat) u64 => Loc;
        pub Prefab: double_map hasher(blake2_128_concat) u128, hasher(blake2_128_concat) (i8, i8, i8) => Block;
    }
}

let conn = http::connect("http://[::1]:9933").compat().await?;
let cl = StateClient::<Hash>::new(conn);

let q = StorageQuery::value::<LastActionId>();
let _: Option<u64> = q.get(&cl, None).await?;

let q = StorageQuery::map::<Voxels, _>((0, 0, 0));
let _: Option<Block> = q.get(&cl, None).await?;

let q = StorageQuery::map::<Actions, _>(12);
let _: Option<Loc> = q.get(&cl, None).await?;

let q = StorageQuery::double_map::<Prefab, _, _>(3, (0, 0, 0));
let _: Option<Block> = q.get(&cl, None).await?;

Implementations

impl<V: FullCodec> StorageQuery<V>[src]

pub fn value<St: StorageValue<V>>() -> Self[src]

Create a storage query for a StorageValue.

pub fn map<St: StorageMap<K, V>, K: FullEncode>(key: K) -> Self[src]

Create a storage query for a value in a StorageMap.

pub fn double_map<St: StorageDoubleMap<K1, K2, V>, K1: FullEncode, K2: FullEncode>(
    key1: K1,
    key2: K2
) -> Self
[src]

Create a storage query for a value in a StorageDoubleMap.

pub async fn get<'_, Hash: Send + Sync + 'static + DeserializeOwned + Serialize>(
    self,
    state_client: &'_ StateClient<Hash>,
    block_index: Option<Hash>
) -> Result<Option<V>, RpcError>
[src]

Send this query over RPC, await the typed result.

Hash should be ::Hash.

Arguments

state_client represents a connection to the RPC server.

block_index indicates the block for which state will be queried. A value of None indicates the latest block.

Trait Implementations

impl<V: Clone> Clone for StorageQuery<V>[src]

impl<V: Debug> Debug for StorageQuery<V>[src]

impl<V: Eq> Eq for StorageQuery<V>[src]

impl<V: Hash> Hash for StorageQuery<V>[src]

impl<V: Ord> Ord for StorageQuery<V>[src]

impl<V: PartialEq> PartialEq<StorageQuery<V>> for StorageQuery<V>[src]

impl<V: PartialOrd> PartialOrd<StorageQuery<V>> for StorageQuery<V>[src]

impl<V> StructuralEq for StorageQuery<V>[src]

impl<V> StructuralPartialEq for StorageQuery<V>[src]

Auto Trait Implementations

impl<V> RefUnwindSafe for StorageQuery<V> where
    V: RefUnwindSafe

impl<V> Send for StorageQuery<V> where
    V: Send

impl<V> Sync for StorageQuery<V> where
    V: Sync

impl<V> Unpin for StorageQuery<V> where
    V: Unpin

impl<V> UnwindSafe for StorageQuery<V> where
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> CheckedConversion for T

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IsType<T> for T[src]

impl<T, Outer> IsWrappedBy<Outer> for T where
    Outer: AsRef<T> + AsMut<T> + From<T>,
    T: From<Outer>, 

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeDebug for T where
    T: Debug

impl<T> MaybeHash for T where
    T: Hash

impl<T> MaybeHash for T where
    T: Hash

impl<T> MaybeRefUnwindSafe for T where
    T: RefUnwindSafe

impl<T> Member for T where
    T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SaturatedConversion for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<S, T> UncheckedInto<T> for S where
    T: UncheckedFrom<S>, 

impl<T, S> UniqueSaturatedInto<T> for S where
    S: TryInto<T>,
    T: Bounded

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,