3 releases
0.0.3 | Aug 22, 2021 |
---|---|
0.0.2 | Aug 22, 2021 |
0.0.1 | Aug 21, 2021 |
#31 in #key-store
20KB
598 lines
mixin-sdk
中文版 The rust sdk of mixin.one. Currently, only clients generated by RSA's keystore are supported.
Installation
- Add dependencies to the
[dependencies]
ofCargo.toml
in the project
[dependencies]
mixin-sdk = "0.0.2"
- 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
- 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"]}
- 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(())
}
- Complete the filling of
client_id
/client_secret
/session_id
/private_key
/pin_token
/pin
. If the scope has no special requirements, fill inFULL
- Execute
cargo run
in the terminal - 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
License
MIT © Richard McRichface
Dependencies
~8–19MB
~267K SLoC