@@ -57,6 +57,31 @@ use serde_json::{
5757
5858pub use crate :: errors:: PatchError ;
5959
60+ pub mod prelude {
61+ pub use super :: {
62+ add_operation,
63+ copy_operation,
64+ escape,
65+ format_ptr,
66+ move_operation,
67+ patch_ext,
68+ remove_operation,
69+ replace_operation,
70+ test_operation,
71+ AddOperation ,
72+ CopyOperation ,
73+ MoveOperation ,
74+ Patch ,
75+ PatchError ,
76+ PatchOperation ,
77+ Pointer ,
78+ PointerBuf ,
79+ RemoveOperation ,
80+ ReplaceOperation ,
81+ TestOperation ,
82+ } ;
83+ }
84+
6085// PatchMode controls what to do if the referenced element does not exist in the object.
6186#[ derive( Debug , Clone , Copy ) ]
6287enum PatchMode {
@@ -69,20 +94,20 @@ pub fn add_operation(path: PointerBuf, value: Value) -> PatchOperation {
6994 PatchOperation :: Add ( AddOperation { path, value } )
7095}
7196
72- pub fn replace_operation ( path : PointerBuf , value : Value ) -> PatchOperation {
73- PatchOperation :: Replace ( ReplaceOperation { path, value } )
74- }
75-
76- pub fn remove_operation ( path : PointerBuf ) -> PatchOperation {
77- PatchOperation :: Remove ( RemoveOperation { path } )
97+ pub fn copy_operation ( from : PointerBuf , path : PointerBuf ) -> PatchOperation {
98+ PatchOperation :: Copy ( CopyOperation { from, path } )
7899}
79100
80101pub fn move_operation ( from : PointerBuf , path : PointerBuf ) -> PatchOperation {
81102 PatchOperation :: Move ( MoveOperation { from, path } )
82103}
83104
84- pub fn copy_operation ( from : PointerBuf , path : PointerBuf ) -> PatchOperation {
85- PatchOperation :: Copy ( CopyOperation { from, path } )
105+ pub fn remove_operation ( path : PointerBuf ) -> PatchOperation {
106+ PatchOperation :: Remove ( RemoveOperation { path } )
107+ }
108+
109+ pub fn replace_operation ( path : PointerBuf , value : Value ) -> PatchOperation {
110+ PatchOperation :: Replace ( ReplaceOperation { path, value } )
86111}
87112
88113pub fn test_operation ( path : PointerBuf , value : Value ) -> PatchOperation {
0 commit comments