titanium_rs/lib.rs
1//! Titanium - The ultimate high-performance Discord API framework.
2//!
3//! This crate provides a high-level wrapper around the Titanium ecosystem:
4//! - `titanium-gateway`: WebSocket connection management
5//! - `titanium-http`: REST API client
6//! - `titanium-model`: Discord data models
7//! - `titanium-cache`: In-memory caching
8//! - `titanium-voice`: Voice support
9//!
10//! # Example
11//!
12//! ```no_run
13//! use titanium_rs::prelude::*;
14//! use async_trait::async_trait;
15//!
16//! struct Handler;
17//!
18//! #[async_trait]
19//! impl EventHandler for Handler {
20//! async fn ready(&self, _: Context, ready: ReadyEventData<'_>) {
21//! println!("Logged in as {}", ready.user.username);
22//! }
23//!
24//! async fn message_create(&self, ctx: Context, msg: Message<'_>) {
25//! if &*msg.content == "!ping" {
26//! let response = titanium_model::builder::MessageBuilder::new().content("Pong!").build();
27//! if let Err(e) = ctx.http.create_message(msg.channel_id, &response).await {
28//! eprintln!("Error sending message: {:?}", e);
29//! }
30//! }
31//! }
32//! }
33//!
34//! #[tokio::main]
35//! async fn main() {
36//! let token = std::env::var("DISCORD_TOKEN").expect("Expected a token in the environment");
37//!
38//! let result = Client::builder(token)
39//! .intents(Intents::GUILD_MESSAGES | Intents::MESSAGE_CONTENT)
40//! .event_handler(Handler)
41//! .build()
42//! .await
43//! .expect("Error creating client")
44//! .start()
45//! .await;
46//!
47//! if let Err(why) = result {
48//! eprintln!("Client error: {:?}", why);
49//! }
50//! }
51//! ```
52
53pub mod client;
54pub mod collector;
55pub mod context;
56pub mod framework;
57pub mod prelude;
58
59// Re-exports
60pub use titanium_cache as cache;
61pub use titanium_gateway as gateway;
62pub use titanium_http as http;
63pub use titanium_model as model;
64pub use titanium_voice as voice;
65
66pub mod error;
67pub use error::TitaniumError;
68
69pub use client::Client;
70pub use client::EventHandler;
71pub use framework::Framework;
72
73#[cfg(feature = "performance")]
74#[global_allocator]
75static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
76
77// Incremental build test modification