Crates.io | traq |
lib.rs | traq |
version | 0.1.5 |
source | src |
created_at | 2023-06-05 23:47:50.2909 |
updated_at | 2024-07-30 13:42:40.772906 |
description | ⚠️ Community Driven ⚠️ traQ v3 API |
homepage | |
repository | https://github.com/traPtitech/rust-traq |
max_upload_size | |
id | 883423 |
size | 984,003 |
⚠️ Community Driven ⚠️ This is a client library for the traQ API, written in Rust.
This crate is updated using openapi-generator.
Add this crate using cargo add traq
, then write in main.rs
:
use std::{env::var, error::Error};
use traq::apis::{channel_api, configuration};
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let access_token = var("BOT_ACCESS_TOKEN")?;
let conf = configuration::Configuration {
bearer_access_token: Some(access_token),
..Default::default()
};
let channels = channel_api::get_channels(&conf, Some(true)).await?;
println!("there are {} public channels", channels.public.len());
Ok(())
}
This crate depends on reqwest as an HTTPS client. As with reqwest, you can select TLS backend through this crate's feature flags.
native-tls
: the system-installed TLS backendrustls-tls
: the TLS library written in Rustnative-tls
is used by default. To use only rustls-tls
, write dependencies as:
[dependencies]
traq.version = "..."
traq.default-features = false
traq.features = ["rustls-tls"]
For more information, see docs in reqwest::tls.