docx_rust/media/
mod.rs

1use crate::schema::SCHEMA_IMAGE;
2
3/// Specifies the type of a media file
4///
5#[derive(Debug, Clone)]
6#[cfg_attr(test, derive(PartialEq))]
7pub enum MediaType {
8    Image,
9}
10
11pub fn get_media_type_relation_type(mt: &MediaType) -> &'static str {
12    match mt {
13        MediaType::Image => SCHEMA_IMAGE,
14    }
15}
16
17pub fn get_media_type(filename: &str) -> Option<MediaType> {
18    if filename.ends_with("png")
19        | filename.ends_with("jpg")
20        | filename.ends_with("jpeg")
21        | filename.ends_with("bmp")
22    {
23        Some(MediaType::Image)
24    } else {
25        None
26    }
27}