Skip to main content

DeclaredEditPlan

Struct DeclaredEditPlan 

Source
pub struct DeclaredEditPlan(/* private fields */);
Expand description

An EditPlan decoded without materializing any extension member.

Decoding an envelope through EditPlan retains every undeclared member as an owned JSON value at all three levels. That is required to round-trip a plan, and it is the dominant cost of decoding a large multi-file plan. A consumer that only validates or applies a plan never reads those values and should not pay for them.

This wrapper recovers identical declared data and reports declared-member errors identically, but skips undeclared members structurally instead of building a key and a value tree for each one. The EditPlan it yields has empty extensions at every level.

§It is not an input-rejection gate

The two decodes do not accept the same documents. Capturing decode materializes each undeclared member into a value, so a member the value model cannot represent — a number outside the representable range, a lone surrogate escape, nesting past the driver’s depth limit — fails the whole decode. This wrapper consumes that member without inspecting it and succeeds. The divergence is confined to content this path never looks at, and tests/declared_divergence.rs pins it.

Use it as a terminal consumer of declared data. Do not use it as the gate that rejects malformed input: PlanLimits does not bound extension payloads either, so a caller that must constrain undeclared content has to decode through EditPlan and enforce its own budget.

§Extensions are dropped, not hidden

The recovered plan is not round-trippable: re-serializing it emits only declared members. Decode through EditPlan whenever the extension members must survive. Validation is unaffected either way — a reserved member name can never reach an extension map through the wire, because a JSON member spelled like a declared field always binds to that field.

§Examples

use weavatrix_edit::DeclaredEditPlan;

let json = r#"{
    "schemaVersion": "weavatrix.edit-plan.v1",
    "operation": "rename_symbol",
    "createdAt": "2026-08-01T12:00:00Z",
    "files": [{
        "path": "src/user.ts",
        "sha256": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
        "language": "typescript",
        "edits": [{
            "startLine": 10, "startChar": 8, "endLine": 10, "endChar": 15,
            "before": "getUser", "after": "getCustomer", "provenance": "EXACT_LSP"
        }]
    }]
}"#;

let declared: DeclaredEditPlan = blazingly_json::from_str(json)?;
let plan = declared.into_plan();
assert!(plan.validate().is_ok());
assert!(plan.extensions.is_empty());
assert!(plan.files[0].extensions.is_empty());

Implementations§

Source§

impl DeclaredEditPlan

Source

pub const fn plan(&self) -> &EditPlan

Borrows the recovered plan.

Source

pub fn into_plan(self) -> EditPlan

Takes the recovered plan, whose extension maps are all empty.

Trait Implementations§

Source§

impl AsRef<EditPlan> for DeclaredEditPlan

Source§

fn as_ref(&self) -> &EditPlan

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for DeclaredEditPlan

Source§

fn clone(&self) -> DeclaredEditPlan

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeclaredEditPlan

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DeclaredEditPlan

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<DeclaredEditPlan> for EditPlan

Source§

fn from(declared: DeclaredEditPlan) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for DeclaredEditPlan

Source§

fn eq(&self, other: &DeclaredEditPlan) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DeclaredEditPlan

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.