mixin-sdk

Crates.iomixin-sdk
lib.rsmixin-sdk
version0.0.3
sourcesrc
created_at2021-08-21 06:50:46.770481
updated_at2021-08-22 10:03:05.109004
descriptionmixin.one network sdk
homepagehttps://github.com/liuzemei/mixin-rust-sdk/blob/main/README.md
repositoryhttps://github.com/liuzemei/mixin-rust-sdk.git
max_upload_size
id440232
size20,855
Neo (liuzemei)

documentation

README

mixin-sdk

中文版 The rust sdk of mixin.one. Currently, only clients generated by RSA's keystore are supported.

Installation

  1. Add dependencies to the [dependencies] of Cargo.toml in the project
[dependencies]
mixin-sdk = "0.0.2"
  1. The terminal executes cargo build to complete the installation

Usage

use mixin_sdk::{keystore::Keystore, Client};

async fn test() -> Result<(), Box<std::error::Error>> {
    let ks = Keystore::new(Keystore {
        client_id: String::from(""),
        client_secret: String::from(""),
        session_id: String::from(""),
        private_key: String::from(""),
        pin_token: String::from(""),
        pin: String::from(""),
        scope: String::from("FULL"),
    });
    let client = Client::new(ks);
    let user = client.user_me().await?;
    println!(
        "user_id:{}\nfull_name:{}\nidentity_number:{}\n",
        user.user_id, user.full_name, user.identity_number
    );
    Ok(())
}

Example

  1. In order to see the execution effect in main.rs, we introduce another package.
[dependencies]
mixin-sdk = "0.0.2"
tokio = {version = "1.2.0", features = ["full"]}
  1. We write the following code in main.rs
use mixin_sdk::{keystore::Keystore, Client};
#[tokio::main]
async fn main() {
    test().await;
}
async fn test() -> Result<(), Box<std::error::Error>> {
    let ks = Keystore::new(Keystore {
        client_id: String::from(""),
        client_secret: String::from(""),
        session_id: String::from(""),
        private_key: String::from(""),
        pin_token: String::from(""),
        pin: String::from(""),
        scope: String::from("FULL"),
    });
    let client = Client::new(ks);
    let user = client.user_me().await?;
    println!(
        "user_id:{}\nfull_name:{}\nidentity_number:{}\n",
        user.user_id, user.full_name, user.identity_number
    );
    Ok(())
}
  1. Complete the filling of client_id/client_secret/session_id/private_key/pin_token/pin. If the scope has no special requirements, fill in FULL
  2. Execute cargo run in the terminal
  3. If the above information is filled in correctly, your robot information should appear on the screen.

If you have any questions, please issue an issue.

Contribute

Acceptable PRs.

Related articles or links

  1. https://developers.mixin.one/document
  2. https://github.com/fox-one/mixin-sdk-go
  3. https://mixin.one

License

MIT © Richard McRichface

Commit count: 6

cargo fmt