Struct substrate_frame_rpc_support::StorageQuery [−][src]
pub struct StorageQuery<V> { /* fields omitted */ }
Expand description
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: Config> 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
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
pub fn double_map<St: StorageDoubleMap<K1, K2, V>, K1: FullEncode, K2: FullEncode>(
key1: K1,
key2: K2
) -> Self
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>
pub async fn get<Hash: Send + Sync + 'static + DeserializeOwned + Serialize>(
self,
state_client: &StateClient<Hash>,
block_index: Option<Hash>
) -> Result<Option<V>, RpcError>
Send this query over RPC, await the typed result.
Hash should be
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
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
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
Mutably borrows from an owned value. Read more
impl<T> CallHasher for T where
T: Hash,
impl<T> CallHasher for T where
T: Hash,
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
impl<T> MaybeDebug for T where
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,