vtubestudio-rs

crates.io docs.rs MIT licensed

A library for interacting with the [VTube Studio API].

Basic usage

This example creates a Client using the provided builder, which:

```rust use vtubestudio::{Client, Error}; use vtubestudio::data::StatisticsRequest;

[tokio::main]

async fn main() -> Result<(), Error> { // An auth token from a previous successful authentication request let storedtoken = Some("...".tostring());

let (mut client, mut new_tokens) = Client::builder()
    .auth_token(stored_token)
    .authentication("Plugin name", "Developer name", None)
    .build_tungstenite();

tokio::spawn(async move {
    // This returns whenever the authentication middleware receives a new auth token.
    // We can handle it by saving it somewhere, etc.
    while let Some(token) = new_tokens.next().await {
        println!("Got new auth token: {}", token);
    }
});

// Use the client to send a `StatisticsRequest`, handling authentication if necessary.
// The return type is inferred from the input type to be `StatisticsResponse`.
let resp = client.send(&StatisticsRequest {}).await?;
println!("VTube Studio has been running for {}ms", resp.uptime);

Ok(())

} ```

For more details, please check the documentation on docs.rs.