Skip to main content

SpliceState

Struct SpliceState 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more