docspec-core
Core event types and traits for DocSpec streaming document conversion
docspec-core is the foundation of DocSpec: the Event type that documents stream as,
the EventSource and EventSink traits that decouple readers from writers, and the
pipe helper that drives one into the other. It reads and writes nothing itself — it
defines the contract every other crate speaks. Streaming, like the rest of DocSpec.
(See the Manifesto for why.)
Add it
[]
= "1"
Speak the contract
A reader is an EventSource, a writer is an EventSink, and pipe moves events from one
into the other until the source runs dry. Implementing a sink is this small — here we
count the events flowing through:
use ;
/// A sink that counts the events flowing through it.
;
Pair it with any EventSource — a DOCX, HTML, or Markdown reader from a sibling crate —
and drive them with pipe(source, sink). Nothing is buffered; events flow one at a time.
What's inside
Event— every document structure DocSpec understands. Theeventmodule documents each variant and its well-formedness rules.EventSource/EventSink/AssetHandle— the reader, writer, and streamed-asset contracts.pipe— connect a source to a sink with no buffering.- Adapters —
SkipEmptyBlocksdrops empty heading/blockquote/paragraph pairs with O(1) look-back;StackTrackingSinkvalidates nesting. Each wraps a source or sink without holding the document.
Related
- Architecture — the streaming pipeline and event model
docspec-coreon docs.rs — every event variant, field, and rule