actix_bililive/lib.rs
1//! A simple stream-based bilibili live client library for the Actix ecosystem.
2//!
3//! *Minimum supported rust version: 1.56.0*
4//!
5//! ## Runtime Support
6//!
7//! This crate supports `actix-rt` (single-threaded `tokio`) runtime.
8//!
9//! ## Features
10//!
11//! - Ergonomic `Stream`/`Sink` interface.
12//! - Easy establishment of connection via given live room id.
13//! - Handles heartbeat packets automatically.
14//! - Auto retry when connection fails (optional).
15//! - Decompresses `Zlib` payloads automatically.
16//!
17//! ## Example
18//!
19//! ```rust
20//! use actix_bililive::{ConfigBuilder, RetryConfig, connect_with_retry};
21//!
22//! use futures::StreamExt;
23//! use log::info;
24//! use serde_json::Value;
25//!
26//! # async fn test() {
27//! let config = ConfigBuilder::new()
28//! .by_uid(1602085)
29//! .await
30//! .unwrap()
31//! .fetch_conf()
32//! .await
33//! .unwrap()
34//! .build();
35//!
36//! let mut stream = connect_with_retry(config, RetryConfig::default()).await.unwrap();
37//! while let Some(e) = stream.next().await {
38//! match e {
39//! Ok(packet) => {
40//! info!("raw: {:?}", packet);
41//! if let Ok(json) = packet.json::<Value>() {
42//! info!("json: {:?}", json);
43//! }
44//! }
45//! Err(e) => {
46//! info!("err: {:?}", e);
47//! }
48//! }
49//! }
50//! #
51//! # }
52//! ```
53
54#![allow(clippy::module_name_repetitions, clippy::future_not_send)]
55
56pub use bililive_core as core;
57#[doc(inline)]
58pub use builder::ConfigBuilder;
59pub use connect::{connect, connect_with_retry};
60
61pub use crate::core::packet::*;
62pub use crate::core::retry::RetryConfig;
63
64mod builder;
65mod connect;
66pub mod errors;
67pub mod stream;