4 releases (2 breaking)

0.3.0 Jul 28, 2022
0.2.0 Jul 8, 2022
0.1.1 Jul 7, 2022
0.1.0 Jul 7, 2022

#184 in WebSocket

Download history 214/week @ 2023-12-05 228/week @ 2023-12-12 317/week @ 2023-12-19 133/week @ 2023-12-26 318/week @ 2024-01-02 192/week @ 2024-01-09 127/week @ 2024-01-16 72/week @ 2024-01-23 80/week @ 2024-01-30 133/week @ 2024-02-06 129/week @ 2024-02-13 184/week @ 2024-02-20 198/week @ 2024-02-27 200/week @ 2024-03-05 171/week @ 2024-03-12 242/week @ 2024-03-19

823 downloads per month
Used in 2 crates

MIT/Apache

64KB
1.5K SLoC

phyllo

Phoenix channels in Rust. This crate uses the Actor model to provide Socket and Channel abstractions for connecting to, receiving and sending messages in a topical fashion. The overall structure is based on the reference JavaScript client.

Example

Warning: the results returned may include NSFW links or comments.

use serde_json::Value;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    // The socket is generic over a Topic.
    let mut socket = SocketBuilder::new(Url::parse("wss://furbooru.org/socket/websocket")?)
        .build::<String>()
        .await;

    // Each channel is generic over an Event and Payload type.
    // For simplicity we use serde_json::Value, but in your own code you should deserialize
    // to something strongly-typed.
    let (_channel, mut subscription) = socket
        .channel::<String, Value, Value>(ChannelBuilder::new("firehose".to_string()))
        .await?;

    loop {
        let v = subscription.recv().await?;
        println!("{:?}", v);
    }
}

Features

TLS is not enabled by default. Enable either of the following for TLS support:

License: MIT OR Apache-2.0

Dependencies

~7–20MB
~285K SLoC