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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//! A simple stream-based bilibili live client library.
//!
//! *Minimum supported rust version: 1.53.0*
//!
//! ## Runtime Support
//!
//! This crate supports both `tokio` and `async-std` runtime.
//!
//! `tokio` support is enabled by default. While used on an `async-std` runtime, change the corresponding dependency in Cargo.toml to
//!
//! ```toml
//! bililive = { version = "0.1", default-features = false, features = ["async-native-tls"] }
//! ```
//!
//! See `Crates Features` section for more.
//!
//! ## Features
//!
//! - Ergonomic `Stream`/`Sink` interface.
//! - Easy establishment of connection via given live room id.
//! - Handles heartbeat packets automatically.
//! - Auto retry when connection fails (optional).
//! - Decompresses `Zlib` payloads automatically.
//!
//! ## Example
//!
//! ```rust
//! # #[cfg(feature = "tokio")]
//! use bililive::connect::tokio::connect_with_retry;
//! use bililive::errors::Result;
//! use bililive::{ConfigBuilder, RetryConfig};
//!
//! use futures::StreamExt;
//! use log::info;
//! use serde_json::Value;
//!
//! # #[cfg(feature = "tokio")]
//! # async fn test() -> Result<()> {
//! let config = ConfigBuilder::new()
//! .by_uid(1602085)
//! .await?
//! .fetch_conf()
//! .await?
//! .build()?;
//!
//! let mut stream = connect_with_retry(config, RetryConfig::default()).await?;
//! while let Some(e) = stream.next().await {
//! match e {
//! Ok(packet) => {
//! info!("raw: {:?}", packet);
//! if let Ok(json) = packet.json::<Value>() {
//! info!("json: {:?}", json);
//! }
//! }
//! Err(e) => {
//! info!("err: {:?}", e);
//! }
//! }
//! }
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ## Crate Features
//!
//! * `tokio-native-tls`(default): Enables `tokio` support with TLS implemented
//! via [tokio-native-tls](https://crates.io/crates/tokio-native-tls).
//! * `tokio-rustls-native-certs`: Enables `tokio` support with TLS implemented
//! via [tokio-rustls](https://crates.io/crates/tokio-rustls) and uses native system certificates found
//! with [rustls-native-certs](https://github.com/rustls/rustls-native-certs).
//! * `tokio-rustls-webpki-roots`: Enables `tokio` support with TLS implemented
//! via [tokio-rustls](https://crates.io/crates/tokio-rustls) and uses the
//! certificates [webpki-roots](https://github.com/rustls/webpki-roots) provides.
//! * `async-native-tls`: Enables `async_std` support with TLS implemented
//! via [async-native-tls](https://crates.io/crates/async-native-tls).
pub use crateConfigBuilder;
pub use crate;
pub use crateBililiveError;
pub use crate;
pub use crateBililiveStream;