Module client

Module client 

Source
Expand description

Discord REST API HTTP client.

This module provides HttpClient for making requests to Discord’s REST API.

§Features

  • Automatic Rate Limiting: Respects Discord’s rate limits with per-route tracking
  • SIMD-Accelerated JSON: Uses simd-json for fast parsing on supported CPUs
  • Connection Pooling: Reuses HTTP/2 connections for efficiency
  • Thread-Local Buffers: Avoids allocations on hot paths

§Performance

The client is optimized for high-throughput scenarios:

  • 30-second request timeout, 10-second connect timeout
  • HTTP/2 with adaptive window sizing
  • TCP_NODELAY for reduced latency

§Example

let http = HttpClient::new("your-bot-token")?;

// Get gateway information
let gateway = http.get_gateway_bot().await?;
println!("Recommended shards: {}", gateway.shards);

Structs§

HttpClient
Discord REST API client.