pub struct Editor<'a> { /* private fields */ }alloc only.Expand description
Incremental editor for canonical CBOR bytes.
Implementations§
Source§impl<'a> Editor<'a>
impl<'a> Editor<'a>
Sourcepub fn options_mut(&mut self) -> &mut EditOptions
pub fn options_mut(&mut self) -> &mut EditOptions
Returns mutable access to editor options.
Sourcepub fn splice<'p>(
&'p mut self,
array_path: &'p [PathElem<'p>],
pos: ArrayPos,
delete: usize,
) -> Result<ArraySpliceBuilder<'p, 'a, 'p>, CborError>
pub fn splice<'p>( &'p mut self, array_path: &'p [PathElem<'p>], pos: ArrayPos, delete: usize, ) -> Result<ArraySpliceBuilder<'p, 'a, 'p>, CborError>
Start building an array splice at array_path.
array_path must resolve to an array at apply time. Indices are interpreted
against the original array (before edits).
§Errors
Returns CborError on invalid paths or malformed splice parameters.
Sourcepub fn push<T: EditEncode<'a>>(
&mut self,
array_path: &[PathElem<'_>],
value: T,
) -> Result<(), CborError>
pub fn push<T: EditEncode<'a>>( &mut self, array_path: &[PathElem<'_>], value: T, ) -> Result<(), CborError>
Append a value to the end of an array.
§Errors
Returns CborError for invalid paths or encoding failure.
Sourcepub fn push_encoded<F>(
&mut self,
array_path: &[PathElem<'_>],
f: F,
) -> Result<(), CborError>
pub fn push_encoded<F>( &mut self, array_path: &[PathElem<'_>], f: F, ) -> Result<(), CborError>
Append an encoded value to the end of an array.
§Errors
Returns CborError for invalid paths or encoding failure.
Sourcepub fn set<T: EditEncode<'a>>(
&mut self,
path: &[PathElem<'_>],
value: T,
) -> Result<(), CborError>
pub fn set<T: EditEncode<'a>>( &mut self, path: &[PathElem<'_>], value: T, ) -> Result<(), CborError>
Set or replace the value at path.
For map keys this performs an upsert; for arrays it replaces the element.
§Errors
Returns CborError on invalid paths, conflicts, or encoding failure.
Sourcepub fn insert<T: EditEncode<'a>>(
&mut self,
path: &[PathElem<'_>],
value: T,
) -> Result<(), CborError>
pub fn insert<T: EditEncode<'a>>( &mut self, path: &[PathElem<'_>], value: T, ) -> Result<(), CborError>
Insert an entry at path.
For map keys this inserts the key. For arrays this inserts before the index.
§Errors
Returns an error if the key already exists or if the path is invalid.
Sourcepub fn replace<T: EditEncode<'a>>(
&mut self,
path: &[PathElem<'_>],
value: T,
) -> Result<(), CborError>
pub fn replace<T: EditEncode<'a>>( &mut self, path: &[PathElem<'_>], value: T, ) -> Result<(), CborError>
Replace an entry at path.
For map keys this replaces the key. For arrays this replaces the element.
§Errors
Returns an error if the key is missing or if the path is invalid.
Sourcepub fn set_raw(
&mut self,
path: &[PathElem<'_>],
value: CborValueRef<'a>,
) -> Result<(), CborError>
pub fn set_raw( &mut self, path: &[PathElem<'_>], value: CborValueRef<'a>, ) -> Result<(), CborError>
Set a value from an existing canonical value reference without re-encoding.
§Errors
Returns CborError on invalid paths or conflicts.
Sourcepub fn set_encoded<F>(
&mut self,
path: &[PathElem<'_>],
f: F,
) -> Result<(), CborError>
pub fn set_encoded<F>( &mut self, path: &[PathElem<'_>], f: F, ) -> Result<(), CborError>
Encode a value using a Encoder and set it at path.
§Errors
Returns CborError if encoding fails or if the encoded bytes are not a single CBOR item.
Sourcepub fn delete(&mut self, path: &[PathElem<'_>]) -> Result<(), CborError>
pub fn delete(&mut self, path: &[PathElem<'_>]) -> Result<(), CborError>
Delete an entry at path.
For map keys this deletes the key. For arrays this deletes the element.
§Errors
Returns an error if the key is missing or if the path is invalid.