mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 19:01:08 +00:00
Add docs for subxt-rpcs and fix example (#1954)
* Add docs for subxt-rpcs and fix example * Add docs bits in Cargo.toml * add missing docsrs cfg_attr --------- Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@ Example usage via `jsonrpsee` feature:
|
||||
use subxt_rpcs::{RpcClient, ChainHeadRpcMethods};
|
||||
|
||||
// Connect to a local node:
|
||||
let client = RpcClient::("ws://127.0.0.1:9944").await?;
|
||||
let client = RpcClient::from_url("ws://127.0.0.1:9944").await?;
|
||||
// Use chainHead/archive V2 methods:
|
||||
let methods = ChainHeadRpcMethods::new(client);
|
||||
|
||||
|
||||
@@ -94,5 +94,9 @@ tower = { workspace = true }
|
||||
hyper = { workspace = true }
|
||||
http-body = { workspace = true }
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
default-features = true
|
||||
rustdoc-args = ["--cfg", "docsrs"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# subxt-rpcs
|
||||
|
||||
This crate provides an interface for interacting with Substrate nodes via the available RPC methods.
|
||||
|
||||
```rust
|
||||
use subxt_rpcs::{RpcClient, ChainHeadRpcMethods};
|
||||
|
||||
// Connect to a local node:
|
||||
let client = RpcClient::from_url("ws://127.0.0.1:9944").await?;
|
||||
// Use a set of methods, here the V2 "chainHead" ones:
|
||||
let methods = ChainHeadRpcMethods::new(client);
|
||||
|
||||
// Call some RPC methods (in this case a subscription):
|
||||
let mut follow_subscription = methods.chainhead_v1_follow(false).await.unwrap();
|
||||
while let Some(follow_event) = follow_subscription.next().await {
|
||||
// do something with events..
|
||||
}
|
||||
```
|
||||
@@ -16,6 +16,8 @@
|
||||
//! The provided RPC client implementations can be used natively (with the default `native` feature
|
||||
//! flag) or in WASM based web apps (with the `web` feature flag).
|
||||
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
#[cfg(any(
|
||||
all(feature = "web", feature = "native"),
|
||||
not(any(feature = "web", feature = "native"))
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
//! Subxt utils fetch metadata.
|
||||
|
||||
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||
|
||||
// Internal helper macros
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
|
||||
Reference in New Issue
Block a user