Tokio
The multi-threaded, asynchronous runtime that powers our concurrent task management and networking.
Rustalink is engineered for extreme performance, leveraging Rust’s safety and concurrency primitives to handle high-density audio streaming with predictable latency.
Rustalink is built on a “Shared-Nothing” architecture where each player is an isolated unit of execution.
Tokio
The multi-threaded, asynchronous runtime that powers our concurrent task management and networking.
Symphonia
A pure Rust audio decoding and media demuxing library, ensuring safety and performance without C dependencies.
Axum
A web framework that provides a fast, ergonomic REST interface and built-in WebSocket support.
Opus
High-fidelity audio encoding used for the final transmission to Discord’s voice servers.
Every track played through Rustalink undergoes a rigorous transformation process to ensure the highest fidelity and lowest overhead.
We use Symphonia for its strict adherence to Rust’s safety guarantees.
All audio processing in Rustalink happens in a 32-bit floating-point (f32) space.
Vec<f32> to avoid the rounding errors and clipping typical of 16-bit integer math.f32 samples are converted back to PCM and encoded into Opus frames.Each voice connection (Player) runs in its own dedicated Tokio task.
PlayerManager and individual Player tasks occurs via high-speed mpsc (Multi-Producer, Single-Consumer) channels.Rustalink avoids the “Stop-the-World” pauses inherent in garbage-collected languages (like Java/JVM).
The following diagram illustrates the lifecycle of a command moving from the client to the audio output.
graph TD
subgraph "Interface Layer (Axum)"
C[Client] --> REST[REST API /play]
C --> WS[WebSocket events]
end
subgraph "Control Plane (Global)"
REST --> PM[Player Manager]
PM --> RT[Route Resolver]
end
subgraph "Data Plane (Isolated Per Player)"
PM -- "Spawn" --> PT[Player Task]
PT --> DEC[Symphonia Decoder]
DEC --> DSP[DSP Filter Stack]
DSP --> ENC[Opus Encoder]
ENC --> UDP[UDP Transmission]
end
subgraph "External Integration"
RT --> YT[YouTube Source]
RT --> SP[Spotify Source]
RT --> HTTP[HTTP/Direct Source]
UDP --> DIS[Discord Voice Server]
end