pub struct NameTree<V> { /* private fields */ }Expand description
A parsed name tree mapping string keys to values of type V.
Implementations§
Source§impl<V> NameTree<V>
impl<V> NameTree<V>
Sourcepub fn parse<S: PdfSource, F>(
root: &Object,
store: &ObjectStore<S>,
convert: F,
) -> DocResult<Self>
pub fn parse<S: PdfSource, F>( root: &Object, store: &ObjectStore<S>, convert: F, ) -> DocResult<Self>
Parse a name tree starting from the given root object.
The convert function transforms each value Object into a V.
Traversal is fully iterative using an explicit stack.
Sourcepub fn count(&self) -> usize
pub fn count(&self) -> usize
Return the number of entries in this name tree.
Corresponds to CPDF_NameTree::GetCount() in PDFium.
Sourcepub fn get_count(&self) -> usize
pub fn get_count(&self) -> usize
Upstream-aligned alias for count().
Corresponds to CPDF_NameTree::GetCount() in PDFium.
Sourcepub fn add(&mut self, name: String, value: V) -> DocResult<()>
pub fn add(&mut self, name: String, value: V) -> DocResult<()>
Add an entry to the name tree, maintaining sorted order.
If an entry with the same name already exists it is replaced. The in-memory tree is updated; to persist the change to a PDF file use rpdfium-edit.
Sourcepub fn delete_by_index(&mut self, index: usize) -> DocResult<()>
pub fn delete_by_index(&mut self, index: usize) -> DocResult<()>
Delete an entry by its index.
Returns DocError::InvalidIndex if index is out of range.
Sourcepub fn delete_by_name(&mut self, name: &str) -> DocResult<()>
pub fn delete_by_name(&mut self, name: &str) -> DocResult<()>
Delete an entry by its name key.
Returns DocError::NotFound if no entry with the given name exists.