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