kitab

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | LICENSE

mod.rs (2076B)


      1 use mime::Mime;
      2 use unic_langid_impl::LanguageIdentifier;
      3 use biblatex::EntryType;
      4 use std::str::FromStr;
      5 
      6 
      7 /// Represents the parts of the metadata schema covered by the Dublin Core vocabulary.
      8 pub struct DCMetaData {
      9     /// Title of work represented by media.
     10     pub title: String,
     11     /// Author(s) of work represented by media. Multiple authors may be specified by separating
     12     /// them with comma.
     13     pub author: String,
     14     /// Type of work represented by media. Maps to bibtex entry types.
     15     pub typ: EntryType,
     16     /// Comma-separated keyword list describing the content.
     17     pub subject: Option<String>,
     18     /// MIME type of the media.
     19     pub mime: Option<Mime>,
     20     /// What language the work represented by this media file is in.
     21     pub language: Option<LanguageIdentifier>,
     22 }
     23 
     24 pub const DC_IRI_TITLE: &str = "https://purl.org/dc/terms/title";
     25 pub const DC_IRI_CREATOR: &str = "https://purl.org/dc/terms/creator";
     26 pub const DC_IRI_SUBJECT: &str = "https://purl.org/dc/terms/subject";
     27 pub const DC_IRI_LANGUAGE: &str = "https://purl.org/dc/terms/language";
     28 pub const DC_IRI_TYPE: &str = "https://purl.org/dc/terms/type";
     29 pub const DC_IRI_MEDIATYPE: &str = "https://purl.org/dc/terms/MediaType";
     30 pub const DC_XATTR_TITLE: &str = "user.dcterms:title";
     31 pub const DC_XATTR_CREATOR: &str = "user.dcterms:creator";
     32 pub const DC_XATTR_SUBJECT: &str = "user.dcterms:subject";
     33 pub const DC_XATTR_LANGUAGE: &str = "user.dcterms:language";
     34 pub const DC_XATTR_TYPE: &str = "user.dcterms:type";
     35 pub const DC_XATTR_MEDIATYPE: &str = "user.dcterms:MediaType";
     36 
     37 impl DCMetaData {
     38     /// Creates a new Dublin Core metadata part with minimal data.
     39     ///
     40     /// `title`, `author` and `entry_type` map to corresponding [DCMetaData](DCMetaData)
     41     /// properties.
     42     pub fn new(title: &str, author: &str, entry_type: EntryType) -> DCMetaData {
     43         DCMetaData{
     44             title: String::from(title),
     45             author: String::from(author),
     46             typ: entry_type,
     47             subject: None,
     48             mime: None,
     49             language: None,
     50         }
     51     }
     52 }