fluxer/lib.rs
1//! # fluxer-rs
2//!
3//! Rust API wrapper for [Fluxer](https://fluxer.app). Handles the gateway
4//! connection, heartbeating, reconnection, and event dispatch.
5//!
6//! # Quick Start
7//!
8//! ```rust,no_run
9//! use fluxer::prelude::*;
10//! use async_trait::async_trait;
11//!
12//! struct MyHandler;
13//!
14//! #[async_trait]
15//! impl EventHandler for MyHandler {
16//! async fn on_ready(&self, _ctx: Context, ready: Ready) {
17//! println!("Logged in as {}", ready.user.username);
18//! }
19//!
20//! async fn on_message(&self, ctx: Context, msg: Message) {
21//! if msg.content.as_deref() == Some("!ping") {
22//! let channel_id = msg.channel_id.as_deref().unwrap_or_default();
23//! let _ = ctx.http.send_message(channel_id, "Pong!").await;
24//! }
25//! }
26//! }
27//!
28//! #[tokio::main]
29//! async fn main() {
30//! rustls::crypto::ring::default_provider()
31//! .install_default()
32//! .expect("Failed to install rustls crypto provider");
33//!
34//! let mut client = Client::builder("your-bot-token")
35//! .event_handler(MyHandler)
36//! .build();
37//!
38//! client.start().await.expect("Client error");
39//! }
40//! ```
41//!
42//! # Rustls Crypto Provider
43//!
44//! You need to install a rustls crypto provider before creating the client, otherwise
45//! it'll panic at runtime. Just add this at the top of `main()`:
46//!
47//! ```rust,no_run
48//! rustls::crypto::ring::default_provider()
49//! .install_default()
50//! .expect("Failed to install rustls crypto provider");
51//! ```
52//!
53//! This is because `rustls` 0.23+ doesn't auto-select a backend when both `ring` and
54//! `aws-lc-rs` are available (livekit pulls in the latter).
55
56pub mod cache;
57pub mod client;
58pub mod event;
59pub mod error;
60pub mod http;
61pub mod model;
62pub mod voice;
63
64/// Re-exports the stuff you'll need most of the time so you can just `use fluxer::prelude::*;` and get going.
65pub mod prelude {
66 pub use crate::cache::Cache;
67 pub use crate::client::{Client, ClientBuilder, Context};
68 pub use crate::error::ClientError;
69 pub use crate::event::EventHandler;
70 pub use crate::model::*;
71 pub use crate::voice::FluxerVoiceConnection;
72}