pub enum Edit<'a> {
Set(&'a [u8]),
Remove,
Put(&'a [u8], &'a [u8]),
Splice {
at: usize,
take: usize,
put: &'a [&'a [u8]],
},
}Expand description
What to do at one place in a document.
Every set of bytes here is an encoded value and not JSON text. The callers
are the JSON.* commands, which have parsed their argument with
Builder::json by this point, and the ones that
compute rather than parse, like JSON.NUMINCRBY, never had text at all.
Variants§
Set(&'a [u8])
Put these bytes in place of the value that is here.
Remove
Take the value that is here out of whatever holds it.
Removing the root is refused, because a document with no value in it is
not a document. JSON.DEL $ deletes the key, which is the keyspace’s
business and not this file’s.
Put(&'a [u8], &'a [u8])
Put a member under this key into the object that is here.
The key replaces the one already there if there is one, so this is both
halves of what JSON.SET does at a path whose last step is a name.
Splice
Replace take elements of the array that is here, from at, with put.
at and take are clamped to the array, so an append is at at or past
the end with take of zero, and a trim is at of zero with take of
the whole length and the kept elements in put.