pub struct Context { /* private fields */ }Expand description
Ordered material with atomic, identity-preserving edits.
A context has no execution identity or terminal state. Generic edits and imports allow local tool material without imposing execution pairing rules.
Implementations§
Source§impl Context
impl Context
Sourcepub fn apply(
&mut self,
replacements: Vec<Replacement>,
appended: Vec<ContextBlock>,
) -> Result<(), EditFailure>
pub fn apply( &mut self, replacements: Vec<Replacement>, appended: Vec<ContextBlock>, ) -> Result<(), EditFailure>
Applies replacements and tail appends as one atomic edit.
Every range is validated against the original block sequence before overlap
resolution. Later overlapping operations invalidate earlier operations in
full, and invalidated operations are not reconsidered. Ranges are half-open:
an insertion at p conflicts with [start, end) when start <= p < end,
while an insertion at end may coexist. Two insertions at the same point
conflict. Even an empty replacement with no inserted blocks participates in
overlap resolution.
An empty edit succeeds. Effective replacement blocks and appended blocks are
checked against every original block, including originals removed by this
edit: an ID may be reused only when its content and metadata are unchanged.
The final sequence must have unique IDs. General edits permit partial tool
material; execution-specific validators enforce pairing. On failure,
the context is unchanged and all input material is returned in
EditFailure.
Sourcepub fn edit(&mut self) -> ContextEdit<'_>
pub fn edit(&mut self) -> ContextEdit<'_>
Starts an exclusive edit builder. Dropping it leaves this context unchanged.
Source§impl Context
impl Context
Sourcepub fn from_blocks(blocks: Vec<ContextBlock>) -> Result<Self, EditFailure>
pub fn from_blocks(blocks: Vec<ContextBlock>) -> Result<Self, EditFailure>
Imports blocks, validating local identity uniqueness and returning all submitted material on failure.
Sourcepub fn blocks(&self) -> &[ContextBlock]
pub fn blocks(&self) -> &[ContextBlock]
Borrows current material in its committed order.
Sourcepub fn into_blocks(self) -> Vec<ContextBlock>
pub fn into_blocks(self) -> Vec<ContextBlock>
Transfers ownership of the current blocks without copying them.
Sourcepub fn frame(&self) -> ContextFrame
pub fn frame(&self) -> ContextFrame
Copies current material into an independent request frame.