1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! 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](https://www.npmjs.com/package/phoenix).
//!
//! # Example
//! Warning: the results returned may include NSFW links or comments.
//! ```no_run
//! # use phyllo::{channel::ChannelBuilder, socket::SocketBuilder};
//! use serde_json::Value;
//! # use url::Url;
//!
//! #[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:
//!
//! - `rustls-tls-native-roots` (uses [`rustls-native-certs`](https://crates.io/crates/rustls-native-certs)
//! for root certificates)
//! - `rustls-tls-webpki-roots` (uses [`webpki-roots`](https://crates.io/crates/webpki-roots) for root
//! certificates)
/// Channels for sending/receiving messages related to a topic.
/// Error handling.
/// Definition of a message in the Phoenix protocol.
/// Socket for sending/receiving messages.