Skip to main content

parse_book_source/
lib.rs

1//! `parse-book-source`:AI 原生的结构化书源引擎。
2//!
3//! 书源是一份显式结构化 JSON(无紧凑字符串 DSL),由 [`Engine`] 驱动:
4//! 搜索 / 浏览 / 书详情 / 目录(含分卷)/ 正文,并内置样例校验回路。
5//! 取页经 [`Fetcher`] 端口抽象,默认 [`ReqwestFetcher`]。
6//!
7//! 分层(见 OpenSpec change `ai-friendly-book-source` 的 design):
8//! - `model` — 纯领域类型。
9//! - `source` — v2 配置(serde 镜像 `book-source.schema.json`),其中 `Rule` 既是配置、
10//!   也是供求值器遍历的语法树。
11//! - `eval` — 规则解释器(Interpreter + Composite)。
12//! - `backend` — 抽取后端(Strategy:css/json/regex/raw)。
13//! - `fetch` — 取页端口(Ports & Adapters)。
14//! - `engine` — 用例(search/explore/book_info/toc/content)+ 有界分页。
15//! - `verify` — 样例校验回路。
16//! - `error` — 分层错误。
17
18pub mod backend;
19#[cfg(feature = "browser")]
20pub mod browser;
21pub mod engine;
22pub mod error;
23pub mod eval;
24pub mod fetch;
25#[cfg(feature = "js")]
26mod js;
27pub mod model;
28pub mod source;
29mod transform;
30pub mod verify;
31mod xpath;
32
33// 公开面:运行时入口(Engine)+ 取页端口 + 配置 + 领域类型 + 校验 + 错误。
34// 规则 AST(`Rule` 等)与求值/抽取细节在 `source` / `eval` / `backend` 下,按需取用。
35pub use engine::Engine;
36pub use error::{BookSourceError, ConfigError, EvalError, FetchError, Result};
37pub use fetch::{FetchRequest, Fetcher, ReqwestFetcher, is_challenge};
38pub use model::{BookInfo, BookListItem, Chapter, Toc, Volume};
39pub use source::{BookSource, Category, FetchMode, UrlOrRule};
40pub use verify::{Check, CheckStatus, DiagnoseReport, VerifyReport, diagnose, verify_sample};
41
42// 反爬:系统浏览器解挑战(`browser` feature)。
43#[cfg(feature = "browser")]
44pub use browser::{
45    AuthDecision, BrowserFetcher, BrowserOptions, BrowserUi, Clearance, EscalatingFetcher,
46    detect_browser,
47};