A complete, secure, and idiomatic Rust SDK for the Mixin Network & Mixin Messenger.
Table of Contents
Features
- Complete: Supports most APIs for Mixin Network and Mixin Messenger.
- Secure: All API requests are automatically signed with JWT.
- Idiomatic Rust: Designed to be asynchronous from the ground up using
tokio
. - Developer Friendly: Provides clear error handling and a simple, function-based API.
Installation
Add the following to your Cargo.toml
:
[]
= { = "https://github.com/lixvyang/mixin-sdk-rs" }
= { = "1", = ["full"] }
Getting Started
Follow these two simple steps to start using the SDK.
Step 1: Create your Keystore File
It is highly recommended to manage your bot's credentials using a keystore.json
file instead of hardcoding them. Create a file named keystore.json
with the following structure:
Security Note: Make sure to add this file to your
.gitignore
to prevent committing your secrets to version control.
Step 2: Write Your Code
Now you can load the SafeUser
from your keystore and make API calls.
use SafeUser;
use user;
use Error;
async
Running Examples
The /examples
directory contains various usage examples. You can run any example using cargo run
.
For instance, to run the get_me.rs
example:
- Make sure you have created your
keystore.json
file. - Set the environment variable.
- Run the example.
Error Handling
All API functions return a Result<T, mixin_sdk_rs::error::Error>
. You can match on the Error
enum to handle different failure scenarios.
// ... inside an async function
if let Err = request_user_me.await
License
This project is licensed under the MIT License. See the LICENSE file for details.