parse_book_source/book_source/
http_config.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct HttpConfig {
    pub timeout: Option<u64>,
    pub header: Option<HashMap<String, String>>,
    /// 请求速率限制(令牌桶算法)
    pub rate_limit: Option<RateLimit>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RateLimit {
    /// 每秒钟最大请求次数
    pub max_count: u64,
    /// 每隔多少秒补充一次令牌
    pub fill_duration: f64,
}