diff --git a/bingus/src/bin_/bytes.rs b/bingus/src/bin_/bytes.rs index 74a0b03..6b059f3 100644 --- a/bingus/src/bin_/bytes.rs +++ b/bingus/src/bin_/bytes.rs @@ -37,7 +37,4 @@ impl Bendable for Bytes { iter.for_each(|e| *e = f(Cow::Borrowed(e))); self } - fn format() -> crate::Format { - crate::Format::Binary - } } diff --git a/bingus/src/doc/pdf.rs b/bingus/src/doc/pdf.rs index 0e9b26d..43a0277 100644 --- a/bingus/src/doc/pdf.rs +++ b/bingus/src/doc/pdf.rs @@ -92,10 +92,6 @@ impl Bendable for PdfDocument { bookmarks, } } - - fn format() -> crate::Format { - crate::Format::Archive - } } #[cfg(test)] diff --git a/bingus/src/doc/shiva.rs b/bingus/src/doc/shiva.rs index 2a98422..d8b08c7 100644 --- a/bingus/src/doc/shiva.rs +++ b/bingus/src/doc/shiva.rs @@ -59,8 +59,4 @@ impl Bendable for ShivaDocument { self.output_format, ) } - - fn format() -> crate::Format { - crate::Format::Doc - } } diff --git a/bingus/src/fnt/fontkit.rs b/bingus/src/fnt/fontkit.rs index bf44dcf..4b8721c 100644 --- a/bingus/src/fnt/fontkit.rs +++ b/bingus/src/fnt/fontkit.rs @@ -46,8 +46,4 @@ impl Bendable for Font { ) .expect("coudn't get font back from bytes after map") } - - fn format() -> crate::Format { - crate::Format::Font - } } diff --git a/bingus/src/img/image.rs b/bingus/src/img/image.rs index e2a0f66..f8edff5 100644 --- a/bingus/src/img/image.rs +++ b/bingus/src/img/image.rs @@ -15,7 +15,7 @@ use num::{ use rayon::iter::ParallelIterator; use thiserror::Error; -use crate::{Bendable, Format, FromDataBytes, IntoDataBytes, TryFromDataBytes}; +use crate::{Bendable, FromDataBytes, IntoDataBytes, TryFromDataBytes}; impl IntoDataBytes for ImageBuffer> where @@ -188,9 +188,6 @@ where iter.for_each(|p| *p = f(Cow::Borrowed(p))); self } - fn format() -> crate::Format { - Format::Image - } } impl IntoDataBytes for DynamicImage { diff --git a/bingus/src/lib.rs b/bingus/src/lib.rs index b13513a..3a48087 100644 --- a/bingus/src/lib.rs +++ b/bingus/src/lib.rs @@ -13,7 +13,7 @@ pub mod txt; pub type Bytes = Vec; -mod dynamic { +pub mod dynamic { #[cfg(feature = "text")] use std::string::FromUtf8Error; use std::{ @@ -40,53 +40,33 @@ mod dynamic { use cfg_if::cfg_if; #[cfg(feature = "fonts")] use font_kit::error::FontLoadingError; - pub use infer::MatcherType; + pub use infer::*; #[cfg(feature = "documents")] use printpdf::PdfDocument; #[cfg(feature = "documents")] use shiva::core::{bytes, Document, DocumentType}; - use strum::{AsRefStr, EnumDiscriminants, EnumString}; use thiserror::Error; - #[derive(EnumDiscriminants)] - #[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")] @@ -165,15 +145,11 @@ mod dynamic { } self } - - fn format() -> Format { - Format::Meta - } } pub type DynamicResult = Result>, OpenError>; - fn guess(t: Option, bytes: Bytes) -> DynamicResult { + pub fn guess(t: Option, bytes: Bytes) -> DynamicResult { use MatcherType::*; t.map(|t| (t.matcher_type(), t.extension())) .map( @@ -244,8 +220,6 @@ mod dynamic { use std::{borrow::Cow, convert::Infallible}; -pub use dynamic::*; - pub trait Bendable: TryFromDataBytes + IntoDataBytes { type Unit; fn bend_into( @@ -263,7 +237,6 @@ pub trait Bendable: TryFromDataBytes + IntoDataBytes { Self::try_from_data_bytes(b.into_data_bytes(), format, crop) } fn map) -> Self::Unit + Sync>(self, f: F) -> Self; - fn format() -> Format; } pub trait IntoDataBytes: Sized { diff --git a/bingus/src/snd/raw.rs b/bingus/src/snd/raw.rs index 0f57acb..4ef1bd4 100644 --- a/bingus/src/snd/raw.rs +++ b/bingus/src/snd/raw.rs @@ -93,8 +93,5 @@ if #[cfg(feature = "rayon")] { self.0.iter_mut().for_each(|e| *e = f(Cow::Borrowed(e))); self } - fn format() -> crate::dynamic::Format { - crate::Format::Sound - } } }} diff --git a/bingus/src/txt/bare.rs b/bingus/src/txt/bare.rs index 5cb3beb..b58741e 100644 --- a/bingus/src/txt/bare.rs +++ b/bingus/src/txt/bare.rs @@ -31,8 +31,4 @@ impl Bendable for Text<'_> { .collect::() .into() } - - fn format() -> crate::Format { - crate::Format::Text - } }