Skip to main content

FieldFlags

Struct FieldFlags 

Source
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

Source

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);
Source

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);
Source

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());
Source

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());
Source

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());
Source

pub const fn is_push_button(self) -> bool

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());

Trait Implementations§

Source§

impl Clone for FieldFlags

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for FieldFlags

Source§

impl Debug for FieldFlags

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FieldFlags

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for FieldFlags

Source§

impl Hash for FieldFlags

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for FieldFlags

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for FieldFlags

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.