bililive_core/
config.rs

1//! Configuration types.
2
3/// The configuration for bilibili live stream connection.
4#[derive(Debug, Clone)]
5pub struct StreamConfig(Box<StreamConfigInner>);
6
7impl StreamConfig {
8    #[must_use]
9    pub fn new(room_id: u64, uid: u64, token: String, servers: Vec<String>) -> Self {
10        Self(Box::new(StreamConfigInner {
11            room_id,
12            uid,
13            token,
14            servers,
15        }))
16    }
17}
18
19impl StreamConfig {
20    /// Live room id (long version).
21    #[must_use]
22    pub const fn room_id(&self) -> u64 {
23        self.0.room_id
24    }
25    /// Live room user id.
26    #[must_use]
27    pub const fn uid(&self) -> u64 {
28        self.0.uid
29    }
30    /// Danmaku server token.
31    #[must_use]
32    pub fn token(&self) -> &str {
33        &self.0.token
34    }
35    /// Danmaku server urls.
36    #[must_use]
37    pub fn servers(&self) -> &[String] {
38        &self.0.servers
39    }
40}
41
42#[derive(Debug, Clone)]
43struct StreamConfigInner {
44    /// Live room id (long version).
45    room_id: u64,
46    /// Live room user id.
47    uid: u64,
48    /// Danmaku server token.
49    token: String,
50    servers: Vec<String>,
51}