Add ListExtractor
This commit is contained in:
@@ -3,7 +3,7 @@ use pile_config::Label;
|
||||
use std::{collections::HashMap, sync::OnceLock};
|
||||
use tracing::trace;
|
||||
|
||||
use crate::{Item, PileValue, SyncReadBridge, extract::Extractor};
|
||||
use crate::{Item, PileValue, SyncReadBridge, extract::ObjectExtractor};
|
||||
|
||||
pub struct EpubMetaExtractor<'a> {
|
||||
item: &'a Item,
|
||||
@@ -78,7 +78,7 @@ impl<'a> EpubMetaExtractor<'a> {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Extractor for EpubMetaExtractor<'_> {
|
||||
impl ObjectExtractor for EpubMetaExtractor<'_> {
|
||||
async fn field<'a>(
|
||||
&'a self,
|
||||
name: &Label,
|
||||
|
||||
@@ -3,7 +3,7 @@ use pile_config::Label;
|
||||
use std::{collections::HashMap, sync::OnceLock};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::{Item, PileValue, SyncReadBridge, extract::Extractor};
|
||||
use crate::{Item, PileValue, SyncReadBridge, extract::ObjectExtractor};
|
||||
|
||||
pub struct EpubTextExtractor<'a> {
|
||||
item: &'a Item,
|
||||
@@ -88,7 +88,7 @@ fn strip_html(html: &str) -> String {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Extractor for EpubTextExtractor<'_> {
|
||||
impl ObjectExtractor for EpubTextExtractor<'_> {
|
||||
async fn field<'a>(
|
||||
&'a self,
|
||||
name: &Label,
|
||||
|
||||
@@ -9,7 +9,7 @@ pub use epub_text::*;
|
||||
|
||||
use crate::{
|
||||
Item, PileValue,
|
||||
extract::{Extractor, MapExtractor},
|
||||
extract::{MapExtractor, ObjectExtractor},
|
||||
};
|
||||
|
||||
pub struct EpubExtractor<'a> {
|
||||
@@ -23,11 +23,11 @@ impl<'a> EpubExtractor<'a> {
|
||||
inner: HashMap::from([
|
||||
(
|
||||
Label::new("text").unwrap(),
|
||||
PileValue::Extractor(Arc::new(EpubTextExtractor::new(item))),
|
||||
PileValue::ObjectExtractor(Arc::new(EpubTextExtractor::new(item))),
|
||||
),
|
||||
(
|
||||
Label::new("meta").unwrap(),
|
||||
PileValue::Extractor(Arc::new(EpubMetaExtractor::new(item))),
|
||||
PileValue::ObjectExtractor(Arc::new(EpubMetaExtractor::new(item))),
|
||||
),
|
||||
]),
|
||||
};
|
||||
@@ -37,7 +37,7 @@ impl<'a> EpubExtractor<'a> {
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl Extractor for EpubExtractor<'_> {
|
||||
impl ObjectExtractor for EpubExtractor<'_> {
|
||||
async fn field<'a>(
|
||||
&'a self,
|
||||
name: &pile_config::Label,
|
||||
@@ -45,7 +45,7 @@ impl Extractor for EpubExtractor<'_> {
|
||||
#[expect(clippy::unwrap_used)]
|
||||
if name.as_str() == "text" {
|
||||
match self.inner.inner.get(name).unwrap() {
|
||||
PileValue::Extractor(x) => return x.field(name).await,
|
||||
PileValue::ObjectExtractor(x) => return x.field(name).await,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user