8 releases (4 breaking)

0.5.2 Apr 21, 2023
0.5.1 Jul 8, 2022
0.5.0 Mar 7, 2022
0.4.0 Dec 3, 2021
0.1.1 Jun 9, 2021

#20 in #trillium

Download history 12/week @ 2023-06-02 9/week @ 2023-06-09 25/week @ 2023-06-16 11/week @ 2023-06-23 24/week @ 2023-06-30 11/week @ 2023-07-07 6/week @ 2023-07-14 15/week @ 2023-07-21 8/week @ 2023-07-28 9/week @ 2023-08-04 10/week @ 2023-08-11 16/week @ 2023-08-18 17/week @ 2023-08-25 9/week @ 2023-09-01 23/week @ 2023-09-08 22/week @ 2023-09-15

71 downloads per month
Used in trillium-channels



Welcome to Trillium!

📖 Guide 📖

The guide provides an architectural overview and lay of the land connecting the trillium crates.

📑 Rustdocs 📑

The rustdocs represent the best way to learn about any of trillium's individual crates and the specific interfaces.


Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


A websocket trillium handler

There are three primary ways to use this crate

With an async function that receives a WebSocketConn

This is the simplest way to use trillium websockets, but does not provide any of the affordances that implementing the WebSocketHandler trait does. It is best for very simple websockets or for usages that require moving the WebSocketConn elsewhere in an application. The WebSocketConn is fully owned at this point, and will disconnect when dropped, not when the async function passed to websocket completes.

use futures_lite::stream::StreamExt;
use trillium_websockets::{Message, WebSocketConn, websocket};

let handler = websocket(|mut conn: WebSocketConn| async move {
while let Some(Ok(Message::Text(input))) = conn.next().await {
conn.send_string(format!("received your message: {}", &input)).await;

Implementing WebSocketHandler

WebSocketHandler provides support for sending outbound messages as a stream, and simplifies common patterns like executing async code on received messages.

Using JsonWebSocketHandler

JsonWebSocketHandler provides a thin serialization and deserialization layer on top of WebSocketHandler for this common use case. See the JsonWebSocketHandler documentation for example usage. In order to use this trait, the json cargo feature must be enabled.


~212K SLoC