add some strum on Format
This commit is contained in:
parent
53bdd265b3
commit
52c15986a8
2 changed files with 20 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "bingus"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description.workspace = true
|
||||
|
|
|
@ -45,31 +45,48 @@ mod dynamic {
|
|||
use printpdf::PdfDocument;
|
||||
#[cfg(feature = "documents")]
|
||||
use shiva::core::{bytes, Document, DocumentType};
|
||||
use strum::EnumDiscriminants;
|
||||
use strum::{AsRefStr, EnumDiscriminants, EnumString};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(EnumDiscriminants)]
|
||||
#[strum_discriminants(name(Format))]
|
||||
#[strum_discriminants(name(Format), derive(EnumString, AsRefStr))]
|
||||
pub enum DynamicBendable<'a> {
|
||||
#[cfg(feature = "pictures")]
|
||||
#[strum_discriminants(strum(serialize = "img", serialize = "image"))]
|
||||
Image(DynamicImage),
|
||||
#[cfg(feature = "binary")]
|
||||
#[strum_discriminants(strum(serialize = "bin", serialize = "binary"))]
|
||||
Binary(Bytes),
|
||||
#[cfg(feature = "music")]
|
||||
#[strum_discriminants(strum(serialize = "snd", serialize = "sound"))]
|
||||
Sound(Audio),
|
||||
#[cfg(feature = "text")]
|
||||
#[strum_discriminants(strum(serialize = "txt", serialize = "text"))]
|
||||
Text(Text<'a>),
|
||||
#[cfg(not(feature = "text"))]
|
||||
Phantom(PhantomData<&'a ()>),
|
||||
#[cfg(feature = "documents")]
|
||||
#[strum_discriminants(strum(serialize = "doc", serialize = "document"))]
|
||||
Doc(ShivaDocument),
|
||||
#[cfg(feature = "documents")]
|
||||
#[strum_discriminants(strum(serialize = "arc", serialize = "archive"))]
|
||||
Archive(PdfDocument),
|
||||
Meta,
|
||||
#[cfg(feature = "fonts")]
|
||||
#[strum_discriminants(strum(serialize = "fnt", serialize = "font"))]
|
||||
Font(FontKitFont),
|
||||
}
|
||||
|
||||
#[cfg(feature = "pictures")]
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn format_str() {
|
||||
use std::str::FromStr;
|
||||
|
||||
assert_eq!("image", Format::Image.as_ref());
|
||||
assert_eq!(Ok(Format::Image), Format::from_str("img"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "shiva")]
|
||||
#[derive(Debug, Error)]
|
||||
#[error("extension is unknown by Shiva")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue