-
-
Notifications
You must be signed in to change notification settings - Fork 0
Rust Core
hyperpolymath edited this page Sep 27, 2026
·
1 revision
rust/pdftool_core — the only implemented, tested part of this repository.
| Edition | 2021 |
| Crate types |
cdylib, rlib
|
| Licence | MPL-2.0 |
#![forbid(unsafe_code)] |
yes |
Lines (src/lib.rs) |
~1030 |
| Unit tests | 6 |
| Crate | Version | Why |
|---|---|---|
lopdf |
0.34 | PDF object model, parsing, serialisation |
serde |
1 (derive) |
Block serialisation across the WASM boundary |
serde-wasm-bindgen |
0.6 | serde ↔ JsValue
|
wasm-bindgen |
0.2 | export surface |
js-sys |
0.3 |
Uint8Array return type |
Nothing else. Cargo.lock is committed and CI runs with --locked.
Two #[wasm_bindgen] exports, plus the Block struct they share:
pub struct Block { pub label: String, pub x: f32, pub y: f32,
pub width: f32, pub height: f32 }Everything else in the crate is private. resolve_object, object_to_number,
rect_from_object, object_to_text, dict_text, the field-descriptor walkers
and apply_field_value are internal machinery.
- Reject empty input (
BW_PDF_EMPTY). -
Document::load_mem(BW_PDF_INVALID). - Resolve
trailer.Root(BW_PDF_ROOT_MISSING/BW_PDF_ROOT_INVALID). - Resolve or materialise
catalog.AcroForm(BW_FORM_*). - Set
NeedAppearances = trueso viewers regenerate appearances. - Walk
AcroForm.Fieldsrecursively, cycle-guarded by aseenset. - Build a
FieldDescriptorper field: partial name, fully-qualified dotted name, inherited field type, and the widget ids underneath it. - Look each name up in the caller's map — fully-qualified first, then partial.
- Dispatch on field type:
Tx/Ch→ text writeback,Btn→ appearance-state writeback, anything else →BW_FILL_UNSUPPORTED_FIELD_TYPE. - If nothing matched and something was supplied →
BW_FILL_NO_MATCHING_FIELDS. -
doc.save_to(BW_FILL_SAVE_FAILED).
- Only
Tx,ChandBtnfield types are written. Signatures (Sig) are not. -
detect_blocksreports widget rectangles only. It does not detect ruled lines, per-character cells or baselines — the "hand spacing" case the project is named for is not implemented yet. - Recursion depth is capped at 48 to bound hostile or cyclic field trees.
-
field_full_nameuses.as the separator, per the PDF convention.
cargo fmt --manifest-path rust/pdftool_core/Cargo.toml -- --check
cargo test --manifest-path rust/pdftool_core/Cargo.toml --locked
cargo clippy --manifest-path rust/pdftool_core/Cargo.toml --locked --all-targets -- -D warningsThere is no Rust toolchain in most sandboxes, so if you cannot run these, say so in the PR rather than implying you did. CI is the only authority on green.