Expand description
The document resource backing + the buffer-snapshot projection
(plugin-host.md §4.2 / §9.6, PH7.3c).
§4.2’s borrows (&Buffer, &Path, &str inside ActiveBufferSnapshot)
cannot cross the WASM boundary. The host projects the metadata into an
owned [buffer::BufferSnapshot] record (project_buffer_snapshot) and
hands the guest a document resource handle for the text. Bulk rope
text never rides the snapshot: the guest calls get-text-range(range) and
the host slices only that range out of the rope (“zero-copy at the slice
level” — the bytes still cross into guest linear memory, but the whole
document never does).
Decision A (locked): the resource is backed by an
Arc<DocumentSnapshot> — a point-in-time immutable view. Edits landing
after the handle is minted never shift byte ranges under the guest mid-read.
The end-to-end guest→host call through the canonical ABI is exercised at
PH7.3d/PH7.4 (the call machinery + the <500ns bench live there); this slice
proves the design at the host layer — the resource is real (wired into the
linker via bindgen’s generated add_to_linker) and its methods + projection
are unit-tested directly.
Structs§
- Document
Resource - Host-side backing for the
documentWIT resource (decision A): a point-in-time immutable snapshot. The bindgenwith:mapping makes this the resource representation, so theStore’sResourceTablestores it directly and [HostDocument] methods receiveResource<DocumentResource>.
Functions§
- project_
buffer_ snapshot - Project the borrow-carrying
ActiveBufferSnapshotinto the owned WIT [buffer::BufferSnapshot] metadata record (§4.2). Bulk text is NOT copied here — it rides thedocumenthandle. A non-UTF-8 path is a typed error (never lossy), matching the boundary convention.