pub struct Engine { /* private fields */ }Expand description
书源运行时引擎。
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(source: BookSource) -> Result<Self>
pub fn new(source: BookSource) -> Result<Self>
用默认 reqwest 取页后端构建。
Sourcepub fn with_fetcher(source: BookSource, fetcher: Arc<dyn Fetcher>) -> Self
pub fn with_fetcher(source: BookSource, fetcher: Arc<dyn Fetcher>) -> Self
注入自定义取页后端(便于测试替身 / 反爬适配器)。
Sourcepub fn source(&self) -> &BookSource
pub fn source(&self) -> &BookSource
暴露只读配置。
Sourcepub async fn search(
&self,
key: &str,
page: u32,
page_size: u32,
) -> Result<Vec<BookListItem>>
pub async fn search( &self, key: &str, page: u32, page_size: u32, ) -> Result<Vec<BookListItem>>
搜索。
Sourcepub async fn explore(
&self,
category_url: &UrlOrRule,
page: u32,
page_size: u32,
) -> Result<Vec<BookListItem>>
pub async fn explore( &self, category_url: &UrlOrRule, page: u32, page_size: u32, ) -> Result<Vec<BookListItem>>
浏览某分类的某一页。
Sourcepub fn explore_categories(&self) -> Vec<Category>
pub fn explore_categories(&self) -> Vec<Category>
浏览分类列表,供上层选择后翻页。
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Engine
impl !RefUnwindSafe for Engine
impl Send for Engine
impl Sync for Engine
impl Unpin for Engine
impl UnsafeUnpin for Engine
impl !UnwindSafe for Engine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more