Owned items, static values
This commit is contained in:
@@ -12,13 +12,13 @@ use crate::{
|
||||
extract::{MapExtractor, ObjectExtractor},
|
||||
};
|
||||
|
||||
pub struct EpubExtractor<'a> {
|
||||
inner: MapExtractor<'a>,
|
||||
pub struct EpubExtractor {
|
||||
inner: MapExtractor,
|
||||
}
|
||||
|
||||
impl<'a> EpubExtractor<'a> {
|
||||
impl EpubExtractor {
|
||||
#[expect(clippy::unwrap_used)]
|
||||
pub fn new(item: &'a Item) -> Self {
|
||||
pub fn new(item: &Item) -> Self {
|
||||
let inner = MapExtractor {
|
||||
inner: HashMap::from([
|
||||
(
|
||||
@@ -37,19 +37,8 @@ impl<'a> EpubExtractor<'a> {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl ObjectExtractor for EpubExtractor<'_> {
|
||||
async fn field<'a>(
|
||||
&'a self,
|
||||
name: &pile_config::Label,
|
||||
) -> Result<Option<&'a PileValue<'a>>, std::io::Error> {
|
||||
#[expect(clippy::unwrap_used)]
|
||||
if name.as_str() == "text" {
|
||||
match self.inner.inner.get(name).unwrap() {
|
||||
PileValue::ObjectExtractor(x) => return x.field(name).await,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
impl ObjectExtractor for EpubExtractor {
|
||||
async fn field(&self, name: &pile_config::Label) -> Result<Option<PileValue>, std::io::Error> {
|
||||
self.inner.field(name).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user