pub struct FieldValues { /* private fields */ }Expand description
Values written to a form’s fields, keyed by fully-qualified name.
The edit buffer, and the reason this crate can fill a form without
mutating anything: the parser’s object store is immutable and its objects
are values, so a write is recorded here and every reader consults it. It
is the same shape as the appearance
AnnotOverlay, for the same reason.
Turning the buffer into a file is apply’s job.
Implementations§
Source§impl FieldValues
impl FieldValues
Sourcepub fn new() -> FieldValues
pub fn new() -> FieldValues
An empty buffer.
use pdfrum_doc::form::FieldValues;
assert!(FieldValues::new().is_empty());Sourcepub fn set(&mut self, name: impl Into<String>, value: impl Into<String>)
pub fn set(&mut self, name: impl Into<String>, value: impl Into<String>)
Records a value for the field with this fully-qualified name, replacing any earlier one.
use pdfrum_doc::form::FieldValues;
let mut values = FieldValues::new();
values.set("name", "Ada");
// Writing again replaces, it does not append.
values.set("name", "Grace");
assert_eq!(values.get("name"), Some("Grace"));
assert_eq!(values.len(), 1);Sourcepub fn get(&self, name: &str) -> Option<&str>
pub fn get(&self, name: &str) -> Option<&str>
What was written for this field, if anything.
use pdfrum_doc::form::FieldValues;
let mut values = FieldValues::new();
values.set("name", "Ada");
assert_eq!(values.get("name"), Some("Ada"));
assert_eq!(values.get("absent"), None);Sourcepub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
pub fn iter(&self) -> impl Iterator<Item = (&str, &str)>
Every recorded write, in the order it was first made.
use pdfrum_doc::form::FieldValues;
let mut values = FieldValues::new();
values.set("b", "2");
values.set("a", "1");
// First-write order, not sorted.
assert_eq!(values.iter().collect::<Vec<_>>(), [("b", "2"), ("a", "1")]);Trait Implementations§
Source§impl Clone for FieldValues
impl Clone for FieldValues
Source§fn clone(&self) -> FieldValues
fn clone(&self) -> FieldValues
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FieldValues
impl Debug for FieldValues
Source§impl Default for FieldValues
impl Default for FieldValues
Source§fn default() -> FieldValues
fn default() -> FieldValues
Returns the “default value” for a type. Read more
impl Eq for FieldValues
Source§impl PartialEq for FieldValues
impl PartialEq for FieldValues
impl StructuralPartialEq for FieldValues
Auto Trait Implementations§
impl Freeze for FieldValues
impl RefUnwindSafe for FieldValues
impl Send for FieldValues
impl Sync for FieldValues
impl Unpin for FieldValues
impl UnsafeUnpin for FieldValues
impl UnwindSafe for FieldValues
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more