1use std::sync::Arc;
2use url::Url;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct UrlInfo {
6 pub size: u64,
7 pub raw_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#[cfg(feature = "sanitize-filename")]
16impl UrlInfo {
17 pub fn filename(&self) -> String {
18 sanitize_filename::sanitize_with_options(
19 &self.raw_name,
20 sanitize_filename::Options {
21 windows: cfg!(windows),
22 truncate: true,
23 replacement: "_",
24 },
25 )
26 }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct FileId {
31 pub etag: Option<Arc<str>>,
32 pub last_modified: Option<Arc<str>>,
33}
34
35impl FileId {
36 pub fn new(etag: Option<&str>, last_modified: Option<&str>) -> Self {
37 Self {
38 etag: etag.map(Arc::from),
39 last_modified: last_modified.map(Arc::from),
40 }
41 }
42 pub fn empty() -> Self {
43 Self {
44 etag: None,
45 last_modified: None,
46 }
47 }
48}