You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
498 B
Rust
23 lines
498 B
Rust
use mime::Mime;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, PartialOrd, PartialEq)]
|
|
pub enum FileType {
|
|
Other = -1,
|
|
Unknown = 0,
|
|
Image = 1,
|
|
Video = 2,
|
|
Audio = 3,
|
|
}
|
|
|
|
impl From<Mime> for FileType {
|
|
fn from(mime_type: Mime) -> Self {
|
|
match mime_type.type_() {
|
|
mime::IMAGE => Self::Image,
|
|
mime::VIDEO => Self::Video,
|
|
mime::AUDIO => Self::Audio,
|
|
_ => Self::Other,
|
|
}
|
|
}
|
|
}
|