pub struct SpliceState<'a> { /* private fields */ }Expand description
Splice state machine. Construct one per serialization pass with the
body_plan slice (the dispatch plan’s body entries, post any
doc-scope prefix the format consumes separately). The event walk
calls advance_at_start on every
StartAnnotation, advance_at_end on every
EndAnnotation, and should_skip on every
other event to decide whether the event falls inside a
handler-owned subtree.
Implementations§
Source§impl<'a> SpliceState<'a>
impl<'a> SpliceState<'a>
Sourcepub fn new(plan: Option<&'a [RenderedNode]>) -> Self
pub fn new(plan: Option<&'a [RenderedNode]>) -> Self
New splice state. None means “no splicing” — every
advance_at_start returns None and should_skip is always
false, so the event walk emits its default rendering for
every annotation. Some(plan) engages splicing against the
supplied plan.
Sourcepub fn advance_at_start(&mut self, label: &str) -> Option<&str>
pub fn advance_at_start(&mut self, label: &str) -> Option<&str>
Call on every Event::StartAnnotation. Returns Some(rendered)
if this annotation should be replaced by raw passthrough content
(and enters skip-state so the body events emit nothing).
Returns None to fall through to default rendering.
The cursor advances only when the next plan entry’s label matches
the event’s label. An unregistered annotation arriving from the
event walker (one without a schema, so no plan entry) leaves the
cursor untouched — otherwise an unknown.label arriving before a
registered acme.task would shift the cursor past the
acme.task entry and the handler output would never splice.
Inside an active splice (skip-depth > 0), nested annotations with their own plan entries (the dispatch walker visits every annotation regardless of nesting) also advance the cursor so the post-splice cursor lands on the next outer entry.
Known limitation: renderable verbatim plan entries don’t
correspond to a StartAnnotation event, so they aren’t advanced
past by this method. The HTML and markdown event walkers don’t
splice verbatim renders today either, so the limitation is
confined to scenarios with both a renderable verbatim and a
downstream registered annotation in the same document — a
pattern not exercised by any current test.
Sourcepub fn should_skip(&self) -> bool
pub fn should_skip(&self) -> bool
True if the current event arrives inside a handler-owned
subtree and should be suppressed. Inspect Start/EndAnnotation
even when this is true (they advance the depth counter); skip
every other event.
Sourcepub fn advance_at_end(&mut self)
pub fn advance_at_end(&mut self)
Call on every Event::EndAnnotation. Pops one level of
skip-depth; the splice region ends when this reaches zero.
Auto Trait Implementations§
impl<'a> Freeze for SpliceState<'a>
impl<'a> RefUnwindSafe for SpliceState<'a>
impl<'a> Send for SpliceState<'a>
impl<'a> Sync for SpliceState<'a>
impl<'a> Unpin for SpliceState<'a>
impl<'a> UnsafeUnpin for SpliceState<'a>
impl<'a> UnwindSafe for SpliceState<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more