pub struct RustChainClient { /* private fields */ }Expand description
The main RustChain API client.
§Example
use rustchain_client::RustChainClient;
let client = RustChainClient::new("https://rustchain.org")?;
let health = client.health().await?;
println!("{:?}", health);Implementations§
Source§impl RustChainClient
impl RustChainClient
Sourcepub fn new(base_url: &str) -> Result<Self, Error>
pub fn new(base_url: &str) -> Result<Self, Error>
Create a new RustChain API client.
§Arguments
base_url- The base URL of the RustChain node (e.g.,"https://rustchain.org"or"https://50.28.86.131").
Accepts self-signed certificates, which is common for RustChain nodes.
Sourcepub fn with_client(base_url: &str, http: Client) -> Self
pub fn with_client(base_url: &str, http: Client) -> Self
Create a client with a custom reqwest::Client.
Sourcepub async fn health(&self) -> Result<HealthResponse, Error>
pub async fn health(&self) -> Result<HealthResponse, Error>
Check node health.
Calls GET /health.
Sourcepub async fn epoch(&self) -> Result<EpochResponse, Error>
pub async fn epoch(&self) -> Result<EpochResponse, Error>
Get current epoch information.
Calls GET /epoch.
Sourcepub async fn miners(&self) -> Result<Vec<Miner>, Error>
pub async fn miners(&self) -> Result<Vec<Miner>, Error>
List active miners on the network.
Calls GET /api/miners.
Sourcepub async fn wallet_balance(&self, wallet: &str) -> Result<WalletBalance, Error>
pub async fn wallet_balance(&self, wallet: &str) -> Result<WalletBalance, Error>
Check a wallet’s RTC balance.
Calls GET /wallet/balance?miner_id={wallet}.
Sourcepub async fn submit_attestation(
&self,
attestation: &AttestationSubmit,
) -> Result<AttestationResponse, Error>
pub async fn submit_attestation( &self, attestation: &AttestationSubmit, ) -> Result<AttestationResponse, Error>
Submit a mining attestation.
Calls POST /attest/submit.
Sourcepub async fn proposals(&self) -> Result<Vec<Proposal>, Error>
pub async fn proposals(&self) -> Result<Vec<Proposal>, Error>
List governance proposals.
Calls GET /governance/proposals.
Sourcepub async fn proposal(&self, id: u64) -> Result<Proposal, Error>
pub async fn proposal(&self, id: u64) -> Result<Proposal, Error>
Get a single governance proposal by ID.
Calls GET /governance/proposal/{id}.
Sourcepub async fn vote(&self, vote: &Vote) -> Result<VoteResponse, Error>
pub async fn vote(&self, vote: &Vote) -> Result<VoteResponse, Error>
Submit a governance vote.
Calls POST /governance/vote.
Sourcepub async fn agent_jobs(&self) -> Result<AgentJobsResponse, Error>
pub async fn agent_jobs(&self) -> Result<AgentJobsResponse, Error>
List open Agent Economy jobs.
Calls GET /agent/jobs.
Auto Trait Implementations§
impl Freeze for RustChainClient
impl !RefUnwindSafe for RustChainClient
impl Send for RustChainClient
impl Sync for RustChainClient
impl Unpin for RustChainClient
impl UnsafeUnpin for RustChainClient
impl !UnwindSafe for RustChainClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more