pub trait HeaderUtils {
// Required methods
fn extract_filename(&self) -> Result<String, Box<dyn Error + Send + Sync>>;
fn extract_file_size(&self) -> Result<u64, Box<dyn Error + Send + Sync>>;
}Required Methods§
Sourcefn extract_filename(&self) -> Result<String, Box<dyn Error + Send + Sync>>
fn extract_filename(&self) -> Result<String, Box<dyn Error + Send + Sync>>
§extract_filename
When response header provides content disposition or any other keys to provide file name or file type, we can extract it from here.
We can also guess file name from the url and content-type too.
Sourcefn extract_file_size(&self) -> Result<u64, Box<dyn Error + Send + Sync>>
fn extract_file_size(&self) -> Result<u64, Box<dyn Error + Send + Sync>>
§extract_file_size
When response header provides content-range, it is easy to extract the actual file size in bytes.
example response: Content-Range bytes 0-0/360996864
From the above response header, we can extract value in bytes
It will help us downloading partial data with multiple threads.
Implementations on Foreign Types§
Source§impl HeaderUtils for HeaderMap
Since HeaderMap is imported from Reqwest, we need to define trait and then
implement it to the HeaderMap struct.
impl HeaderUtils for HeaderMap
Since HeaderMap is imported from Reqwest, we need to define trait and then implement it to the HeaderMap struct.