fast_down/
url_info.rs

1use std::sync::Arc;
2use url::Url;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct UrlInfo {
6    pub size: u64,
7    /// 服务器返回的原始文件名,必须清洗掉不合法字符才能安全使用
8    pub name: String,
9    pub supports_range: bool,
10    pub fast_download: bool,
11    pub final_url: Url,
12    pub file_id: FileId,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq)]
16pub struct FileId {
17    pub etag: Option<Arc<str>>,
18    pub last_modified: Option<Arc<str>>,
19}
20
21impl FileId {
22    pub fn new(etag: Option<&str>, last_modified: Option<&str>) -> Self {
23        Self {
24            etag: etag.map(Arc::from),
25            last_modified: last_modified.map(Arc::from),
26        }
27    }
28    pub fn empty() -> Self {
29        Self {
30            etag: None,
31            last_modified: None,
32        }
33    }
34}