pub struct FieldFlags(/* private fields */);Expand description
A field’s /Ff flag word (ISO 32000-1 tables 227–230).
Kept as the raw word rather than a set, and deliberately without the
contains / union algebra its two sibling flag types have: the meaning
of a bit depends on the field type, so the same bit 26 is “file select” on
a text field and “sort” on a choice field, and FieldFlags::COMBO | FieldFlags::MULTILINE would be a lie. The predicates below — the ones
whose reading is type-independent or whose type is implied by the name —
are the API. FieldFlags::bits and FieldFlags::from_bits exist for
round-tripping the word itself, unknown bits included.
use pdfrum_doc::form::FieldFlags;
// Bit 1 is `ReadOnly` on every field type.
assert!(FieldFlags::from_bits(1).is_read_only());
// A reserved bit survives the trip.
assert_eq!(FieldFlags::from_bits(1 << 40).bits(), 1 << 40);Implementations§
Source§impl FieldFlags
impl FieldFlags
Sourcepub const fn bits(self) -> i64
pub const fn bits(self) -> i64
The raw /Ff word, including every bit no predicate here reads.
use pdfrum_doc::form::FieldFlags;
assert_eq!(FieldFlags::from_bits(1 << 12).bits(), 1 << 12);Sourcepub const fn from_bits(bits: i64) -> Self
pub const fn from_bits(bits: i64) -> Self
The word as written in the file. Unknown bits are retained: a bit
whose meaning belongs to a /FT this type knows nothing about is
kept, not dropped.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1).is_read_only());
// A bit belonging to a `/FT` this type knows nothing about survives.
assert_eq!(FieldFlags::from_bits(1 << 40).bits(), 1 << 40);Sourcepub const fn is_read_only(self) -> bool
pub const fn is_read_only(self) -> bool
Bit 1: the field may not be changed.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 0).is_read_only());Sourcepub const fn is_required(self) -> bool
pub const fn is_required(self) -> bool
Bit 2: the field must have a value when the form is submitted.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 1).is_required());Sourcepub const fn is_radio(self) -> bool
pub const fn is_radio(self) -> bool
Bit 16, on a /Btn: the field is a radio button rather than a check
box.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 15).is_radio());Bit 17, on a /Btn: the field is a push button and holds no value.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 16).is_push_button());Sourcepub const fn is_combo(self) -> bool
pub const fn is_combo(self) -> bool
Bit 18, on a /Ch: the field is a drop-down rather than a list box.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 17).is_combo());Sourcepub const fn is_editable_combo(self) -> bool
pub const fn is_editable_combo(self) -> bool
Bit 19, on a /Ch: the combo box includes an editable text box.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 18).is_editable_combo());Sourcepub const fn is_multi_select(self) -> bool
pub const fn is_multi_select(self) -> bool
Bit 22, on a /Ch: more than one option may be selected at once.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 21).is_multi_select());Sourcepub const fn is_multiline(self) -> bool
pub const fn is_multiline(self) -> bool
Bit 13, on a /Tx: the field accepts more than one line.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 12).is_multiline());Sourcepub const fn is_password(self) -> bool
pub const fn is_password(self) -> bool
Bit 14, on a /Tx: the field’s contents are obscured as they are
typed.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 13).is_password());Sourcepub const fn is_comb(self) -> bool
pub const fn is_comb(self) -> bool
Bit 25, on a /Tx: the text is laid out in equally spaced cells.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::from_bits(1 << 24).is_comb());Sourcepub const fn scrolls(self) -> bool
pub const fn scrolls(self) -> bool
Bit 24, on a /Tx: whether the field scrolls to fit more text than
its rectangle holds.
The positive reading of the spec’s DoNotScroll bit: a field scrolls
unless the bit is set.
use pdfrum_doc::form::FieldFlags;
// The positive reading: a field scrolls unless `DoNotScroll` is set.
assert!(FieldFlags::default().scrolls());
assert!(!FieldFlags::from_bits(1 << 23).scrolls());Sourcepub const fn spell_checks(self) -> bool
pub const fn spell_checks(self) -> bool
Bit 23, on a /Tx or /Ch: whether the value is spell-checked.
The positive reading of the spec’s DoNotSpellCheck bit.
use pdfrum_doc::form::FieldFlags;
assert!(FieldFlags::default().spell_checks());
assert!(!FieldFlags::from_bits(1 << 22).spell_checks());