fill todos on dynamic open
This commit is contained in:
parent
6e37c21bf2
commit
2a93d99841
1 changed files with 17 additions and 10 deletions
|
@ -26,7 +26,7 @@ mod dynamic {
|
|||
#[cfg(feature = "documents")]
|
||||
use super::doc::ShivaDocument;
|
||||
#[cfg(feature = "fonts")]
|
||||
use super::fnt::Font;
|
||||
use super::fnt::Font as FontKitFont;
|
||||
#[cfg(feature = "pictures")]
|
||||
use super::img::{self, DynamicImage};
|
||||
#[cfg(feature = "music")]
|
||||
|
@ -36,6 +36,8 @@ mod dynamic {
|
|||
use super::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes};
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
#[cfg(feature = "fonts")]
|
||||
use font_kit::error::FontLoadingError;
|
||||
use infer::MatcherType;
|
||||
#[cfg(feature = "documents")]
|
||||
use printpdf::PdfDocument;
|
||||
|
@ -63,7 +65,7 @@ mod dynamic {
|
|||
Archive(PdfDocument),
|
||||
Meta,
|
||||
#[cfg(feature = "fonts")]
|
||||
Font(Font),
|
||||
Font(FontKitFont),
|
||||
}} else {
|
||||
#[derive(EnumDiscriminants)]
|
||||
#[strum_discriminants(name(Format))]
|
||||
|
@ -80,7 +82,7 @@ mod dynamic {
|
|||
Archive(PdfDocument),
|
||||
Meta,
|
||||
#[cfg(feature = "fonts")]
|
||||
Font(Font),
|
||||
Font(FontKitFont),
|
||||
}
|
||||
}}
|
||||
|
||||
|
@ -117,6 +119,9 @@ mod dynamic {
|
|||
#[cfg(feature = "documents")]
|
||||
#[error("document: {0}")]
|
||||
Document(#[from] ShivaError),
|
||||
#[cfg(feature = "fonts")]
|
||||
#[error("font: {0:?}")]
|
||||
Font(#[from] FontLoadingError),
|
||||
}
|
||||
|
||||
impl TryFromDataBytes for File {
|
||||
|
@ -190,7 +195,7 @@ mod dynamic {
|
|||
.map_err(OpenError::Pdf)?,
|
||||
),
|
||||
#[cfg(feature = "documents")]
|
||||
Archive => {
|
||||
Archive | Doc => {
|
||||
let document_type = DocumentType::from_extension(extension)
|
||||
.ok_or(ShivaUnknownExtensionError)
|
||||
.map_err(ShivaError::UnknownExtension)?;
|
||||
|
@ -203,10 +208,14 @@ mod dynamic {
|
|||
document_type,
|
||||
))
|
||||
}
|
||||
Book => todo!(),
|
||||
Doc => todo!(),
|
||||
#[cfg(feature = "fonts")]
|
||||
Font => todo!(),
|
||||
Font => DynamicBendable::Font(FontKitFont::try_from_data_bytes(
|
||||
File::open(path)?
|
||||
.bytes()
|
||||
.collect::<Result<Bytes, io::Error>>()?,
|
||||
(),
|
||||
Default::default(),
|
||||
)?),
|
||||
#[cfg(feature = "text")]
|
||||
Text => DynamicBendable::Text(crate::txt::Text::try_from_data_bytes(
|
||||
File::open(path)?
|
||||
|
@ -251,7 +260,7 @@ mod dynamic {
|
|||
.map_err(OpenError::Pdf)?,
|
||||
),
|
||||
#[cfg(feature = "documents")]
|
||||
Archive => {
|
||||
Archive | Doc => {
|
||||
let document_type = DocumentType::from_extension(extension)
|
||||
.ok_or(ShivaUnknownExtensionError)
|
||||
.map_err(ShivaError::UnknownExtension)?;
|
||||
|
@ -264,8 +273,6 @@ mod dynamic {
|
|||
document_type,
|
||||
))
|
||||
}
|
||||
Book => todo!(),
|
||||
Doc => todo!(),
|
||||
#[cfg(feature = "fonts")]
|
||||
Font => todo!(),
|
||||
#[cfg(feature = "text")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue