rust-io 0.3.0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rust_io/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .rust_io import *
2
+
3
+ __doc__ = rust_io.__doc__
4
+ if hasattr(rust_io, "__all__"):
5
+ __all__ = rust_io.__all__
Binary file
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: rust-io
3
+ Version: 0.3.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: License :: OSI Approved :: Apache Software License
8
+ Classifier: Operating System :: POSIX :: Linux
9
+ Classifier: Operating System :: MacOS
10
+ Classifier: Operating System :: Microsoft :: Windows
11
+ Summary: High-performance Rust native extensions: generic async I/O (local/HTTP/S3), literature search, MinerU parsing, archives, and SHA-256 dedup.
12
+ Author: Lingua Seeker Team
13
+ License-Expression: Apache-2.0
14
+ Requires-Python: >=3.12
15
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
16
+ Project-URL: Homepage, https://github.com/Ruri-Ichigyo/rust-io
17
+ Project-URL: Repository, https://github.com/Ruri-Ichigyo/rust-io
18
+
19
+ # rust-io
20
+
21
+ > Lingua Seeker 的 PyO3 门面 crate,将 `net-io`、`files-io` 和 `io-py` 注册为 `rust_io` Python 模块的子模块。
22
+
23
+ ## 概览
24
+
25
+ `rust-io` 是唯一构建为 `cdylib`(`.so`/`.pyd`)的 crate,通过 `import rust_io` 加载。它本身不包含业务逻辑,仅负责:
26
+
27
+ 1. 创建 `rust_io.net` 子模块,注册 `net-io` 的所有 `#[pyfunction]`
28
+ 2. 创建 `rust_io.files` 子模块,注册 `files-io` 的所有 `#[pyfunction]` 和 `#[pyclass]`
29
+ 3. 创建 `rust_io.io` 子模块,注册 `io-py` 的通用异步 I/O 函数
30
+ 4. 通过 `sys.modules` 注册子模块,使其可通过 `import rust_io.net` / `rust_io.files` / `rust_io.io` 直接访问
31
+
32
+ ## 公开 API
33
+
34
+ `rust-io` 本身不定义业务 API,完整 API 参考见各子 crate:
35
+
36
+ | Python 模块 | 来源 crate | 说明 |
37
+ |-------------|-----------|------|
38
+ | `rust_io.net` | [net-io](../net-io/README.md) | 15 个文献数据源、MinerU API、Web 爬取 |
39
+ | `rust_io.files` | [files-io](../files-io/README.md) | File 类、批量操作、去重、工具函数 |
40
+ | `rust_io.io` | [io-core](../io-core/README.md) | 通用异步 I/O:本地/HTTP/S3、多路复用、流式传输 |
41
+
42
+ ### `rust_io.net` 注册的函数
43
+
44
+ | 函数 | 说明 |
45
+ |------|------|
46
+ | `fetch_one` | 单数据源文献搜索/下载 |
47
+ | `fetch_multi` | 并行多数据源搜索 |
48
+ | `scrape_web` | 数据源网页爬取 |
49
+ | `scrape_html` | CSS 选择器 HTML 解析 |
50
+ | `extract_pdf_links` | 提取 PDF 链接 |
51
+ | `download_file` | 文件下载 |
52
+ | `mineru_create_task` | MinerU 创建解析任务 |
53
+ | `mineru_get_result` | MinerU 查询任务结果 |
54
+ | `mineru_batch_submit` | MinerU 批量提交 |
55
+ | `mineru_batch_result` | MinerU 批量结果查询 |
56
+ | `mineru_create_upload_url` | MinerU 获取上传 URL |
57
+ | `mineru_create_batch_upload_urls` | MinerU 批量获取上传 URL |
58
+ | `mineru_upload_local_file` | MinerU 上传单个本地文件 |
59
+ | `mineru_upload_local_files` | MinerU 上传多个本地文件 |
60
+
61
+ ### `rust_io.files` 注册的函数/类
62
+
63
+ | 名称 | 类型 | 说明 |
64
+ |------|------|------|
65
+ | `File` | class | 统一文件操作(本地 + S3) |
66
+ | `batch_copy` | function | 批量文件复制 |
67
+ | `batch_compress` | function | 批量目录压缩 |
68
+ | `batch_copy_async` | function | 异步批量复制 |
69
+ | `check_duplicate` | function | 文件去重检查 |
70
+ | `batch_hash` | function | 批量 SHA-256 哈希 |
71
+ | `compute_sha256` | function | 单文件 SHA-256 |
72
+ | `write_file` | function | 写入字节数据 |
73
+ | `validate_pdf_magic` | function | PDF 魔数校验 |
74
+
75
+ ### `rust_io.io` 注册的函数
76
+
77
+ | 函数 | 说明 |
78
+ |------|------|
79
+ | `read` / `read_range` | 读取整个对象 / 指定字节区间 |
80
+ | `write` | 写入 bytes/bytearray/memoryview/str |
81
+ | `stat` / `list` / `delete` / `copy` | 元数据、目录列举、删除、复制 |
82
+ | `read_many` / `write_many` / `copy_many` | 有界并发批处理,结果按输入顺序返回 |
83
+ | `read_any` | 多镜像竞速,返回首个成功结果 |
84
+ | `download` / `upload` | 流式下载/上传(不整文件驻留内存) |
85
+ | `hash` / `hash_many` | 流式 SHA-256 / rayon 并行批哈希 |
86
+
87
+ ## 架构
88
+
89
+ ```
90
+ rust-io/src/
91
+ └── lib.rs # #[pymodule] rust_io — 挂载 net、files、io 子模块
92
+ ```
93
+
94
+ ### 子模块注册机制
95
+
96
+ `net-io` 和 `files-io` 各自用 `#[pymodule(submodule)]` 声明 Python 子模块并导出自己的 API,`rust-io` 只负责挂载,不再逐个重复注册函数:
97
+
98
+ ```rust
99
+ #[pymodule]
100
+ fn rust_io(m: &Bound<'_, PyModule>) -> PyResult<()> {
101
+ let py = m.py();
102
+ let net = pyo3::wrap_pymodule!(net_io::py::net)(py);
103
+ register_submodule(m, "net", "rust_io.net", net.bind(py))?;
104
+ let files = pyo3::wrap_pymodule!(files_io::py::files)(py);
105
+ register_submodule(m, "files", "rust_io.files", files.bind(py))?;
106
+ let io = pyo3::wrap_pymodule!(io_py::io)(py);
107
+ register_submodule(m, "io", "rust_io.io", io.bind(py))?;
108
+ Ok(())
109
+ }
110
+ ```
111
+
112
+ `register_submodule` 完成三步操作:
113
+ 1. `parent.add(name, submodule)` — 挂载为父模块属性
114
+ 2. 设置 `submodule.__name__ = "rust_io.net"`(完整限定名)
115
+ 3. `sys.modules["rust_io.net"] = submodule` — 使 `import rust_io.net` 可用
116
+
117
+ 新增函数只需在所属 crate 的 `#[pymodule]` 中导出,门面 crate 无需改动。
118
+
119
+ ## 使用示例
120
+
121
+ ```python
122
+ # 通过 rust_io 门面访问所有功能
123
+ import rust_io
124
+
125
+ # 或直接导入子模块
126
+ import rust_io.net as net_io
127
+ import rust_io.files as files_io
128
+
129
+ # 文献搜索
130
+ result = await net_io.fetch_one("crossref", "search", {"query": "CRISPR"})
131
+
132
+ # 文件操作
133
+ f = files_io.File("/tmp/output.txt")
134
+ f.write("hello")
135
+ print(f.read(as_text=True))
136
+
137
+ # 通用异步 I/O(本地/HTTP/S3 统一 URI)
138
+ import rust_io.io as io_io
139
+ await io_io.write("/tmp/report.bin", b"payload")
140
+ results = await io_io.read_many(
141
+ ["/tmp/a.bin", "s3://bucket/b.bin", "https://example.com/c.bin"],
142
+ limit=3,
143
+ )
144
+ await io_io.download("https://example.com/paper.pdf", "/tmp/paper.pdf")
145
+ ```
146
+
147
+ ## 构建
148
+
149
+ ```bash
150
+ # 从仓库根目录构建(maturin 会自动解析 Cargo.toml 中的 path 依赖)
151
+ uv run maturin develop --release -m crates/rust-io/Cargo.toml
152
+ ```
153
+
154
+ 构建产物为 `rust_io.so`(Linux/macOS)或 `rust_io.pyd`(Windows),包含 `net-io`、`files-io` 和 `io-core` 的全部代码(静态链接)。
155
+
156
+ ## 依赖
157
+
158
+ | 依赖 | 版本 | 说明 |
159
+ |------|------|------|
160
+ | `pyo3` | `0.30` | Python 绑定(extension-module) |
161
+ | `net-io` | path | HTTP/Web I/O crate(提供 `rust_io.net`) |
162
+ | `files-io` | path | 文件 I/O crate(提供 `rust_io.files`) |
163
+ | `io-py` | path | 通用 I/O 绑定 crate(提供 `rust_io.io`) |
164
+
@@ -0,0 +1,6 @@
1
+ rust_io/__init__.py,sha256=ZFZcR0y8kogItIkJ-4T5n23sR5pBZxG3XZl8HEXbGJg,111
2
+ rust_io/rust_io.cp313-win_amd64.pyd,sha256=dCMsNp0jERfdrnDYeNIeji2aSltdExXe313zkIFhKoI,22078976
3
+ rust_io-0.3.0.dist-info/METADATA,sha256=Uad1PeYsRUAdP1ch6yhML7gEUVtDudJ7XKOAXWjLHuA,6581
4
+ rust_io-0.3.0.dist-info/WHEEL,sha256=1CCnYT4CkPGtkem-vV3hqFTPRTmfZy2aMkAyn2cGMqA,97
5
+ rust_io-0.3.0.dist-info/sboms/rust-io.cyclonedx.json,sha256=9SCB7OnJ182VZCeHFCIJs69pEOpYaHWEyD932Ig3trg,344626
6
+ rust_io-0.3.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.16.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64