Skip to main content

Module patchable

Module patchable 

Source
Expand description

Format-agnostic patch application traits Format-agnostic patch application

This module provides the Patchable trait for applying patches to values. It extends DiffableValue with mutation capabilities needed for patch application.

§Key Types

  • Patchable - Trait for values that can have patches applied
  • PatchError - Errors that can occur during patch application

§Example

use fionn_core::patchable::{Patchable, apply_patch};
use fionn_core::diffable::{GenericPatch, GenericPatchOperation};

let mut target = serde_json::json!({"name": "Alice"});
let patch = GenericPatch::with_operations(vec![
    GenericPatchOperation::Replace {
        path: "/name".to_string(),
        value: serde_json::json!("Bob"),
    },
]);

apply_patch(&mut target, &patch)?;
assert_eq!(target["name"], "Bob");

Enums§

PatchError
Errors that can occur during patch application

Traits§

Patchable
Trait for values that can have patches applied

Functions§

apply_operation
Apply a single operation to a value
apply_patch
Apply a patch to a value
parse_pointer
Parse a JSON Pointer path into segments