Rust

You are here:
< Back

Rust Installation

Rust can be installed by following this guide

#Installation

Add the following to your Cargo.toml:

[dependencies]
qredit-client = {git = "https://github.com/qreditm/rust-client", branch = "master" }

Development setup

If you want to contribute to the code of this package execute the following commands

  1. Fork the package
  2. Clone your forked repository
$ git clone https://github.com/<githubusername>/rust-client
  1. Next, move into the fresh cloned directory
$ cd rust-client
  1. Install the dependencies
$ cargo build
  1. Dependencies are now installed, you can now run the tests to see if everything is running like it should
$ cargo test

Usage

Initialization

extern crate qredit_client;

use qredit_client::connection::Connection;
// For V2
use qredit_client::api::two::Two;

fn main() {
    // For v2
    let v2 = Connection::<Two>::new("http://my.qredit.node:port/api/");
    // Parameters are passed as a Vec of string tuples (key, value).
    let params = Vec::<(String, String)>::new();
    // ...
}

Blocks V2

// ...
let blocks = v2.blocks.all(&params);
println!("{:?}", blocks);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})

Delegates V2

// ...
let delegates = v2.delegates.all(&params);
println!("{:?}", delegates);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})

Node – V2

// ...
let node = v2.node.status().unwrap();
println!("{:?}", node);

... > Response { meta
... > ...
... > }

Peers – V2

// ...
let peers = v2.peers.all(&params);
println!("{:?}", peers);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})

Transactions – V2

// ...
let transactions = v2.transactions.all(&params).unwrap();
println!("{:?}", transactions);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})

Votes – V2

// ...
let votes = v2.votes.all(&params).unwrap();
println!("{:?}", votes);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})

Wallets – V2

// ...
let wallets = v2.wallets.all(&params).unwrap();
println!("{:?}", wallets);

... > Ok(Response { meta: Some(Meta {
... > ...
... > })})
Last Updated On January 15, 2019