Mercurial > core / rust/lib/obj/src/object/doc.rs
changeset 698: |
96958d3eb5b0 |
parent: |
8e94959e96bd
|
author: |
Richard Westhaver <ellis@rwest.io> |
date: |
Fri, 04 Oct 2024 22:04:59 -0400 |
permissions: |
-rw-r--r-- |
description: |
fixes |
3 //! Document object types 5 use serde::{Deserialize, Serialize}; 6 use std::{fmt, str::FromStr}; 9 #[derive(Serialize, Deserialize, Debug, Hash, PartialEq)] 11 pub extension: DocExtension, 15 pub fn new(ext: &str) -> Self { 17 extension: DocExtension::from_str(ext).unwrap(), 22 impl Default for Doc { 23 fn default() -> Self { 28 impl Objective for Doc {} 30 /// Document extensions. Use in filenames and IO matching in some 32 #[derive(Serialize, Deserialize, Debug, Hash, PartialEq)] 33 pub enum DocExtension { 40 impl fmt::Display for DocExtension { 41 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 43 DocExtension::OrgExt => write!(f, "org"), 44 DocExtension::PdfExt => write!(f, "pdf"), 45 DocExtension::HtmlExt => write!(f, "html"), 46 DocExtension::None => write!(f, ""), 51 impl FromStr for DocExtension { 53 fn from_str(input: &str) -> Result<DocExtension, Self::Err> { 55 "org" => Ok(DocExtension::OrgExt), 56 "pdf" => Ok(DocExtension::PdfExt), 57 "html" => Ok(DocExtension::HtmlExt), 58 "" => Ok(DocExtension::None),