file/lib.rs
1use std::fmt::Debug;
2
3#[derive(Clone)]
4pub struct File {
5 pub name: String,
6 pub content: Vec<u8>,
7}
8
9impl Debug for File {
10 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11 f.debug_struct("File")
12 .field("name", &self.name)
13 .field("content", &format!("{} bytes", self.content.len()))
14 .finish()
15 }
16}
17
18impl File {
19 pub fn mime_type(&self) -> String {
20 mime_guess::from_path(&self.name)
21 .first_or_octet_stream()
22 .to_string()
23 }
24}