Skip to main content

FieldKind

Enum FieldKind 

Source
pub enum FieldKind {
    Text,
    Check,
    Radio,
    Button,
    Combo,
    List,
    Signature,
}
Expand description

What kind of control a form field is (ISO 32000-1 §12.7.4).

The variants are the /FT values crossed with the two /Ff bits that split them: a /Btn is a push button, a radio button or a check box depending on bits 17 and 16, and a /Ch is a combo box or a list box depending on bit 18.

Variants§

§

Text

A text field (/Tx).

§

Check

A check box (/Btn with neither the push-button nor the radio bit).

§

Radio

A radio button (/Btn with bit 16 set).

§

Button

A push button (/Btn with bit 17 set) — it holds no value.

§

Combo

A drop-down (/Ch with bit 18 set).

§

List

A list box (/Ch without bit 18).

§

Signature

A signature field (/Sig).

Implementations§

Source§

impl FieldKind

Source

pub fn classify(field_type: &[u8], flags: FieldFlags) -> Option<FieldKind>

Classifies a field from its /FT and /Ff.

Returns None for a node with no field type at all, which is how the walk tells a naming-only interior node from a terminal field.

use pdfrum_doc::form::{FieldFlags, FieldKind};

assert_eq!(FieldKind::classify(b"Tx", FieldFlags::default()), Some(FieldKind::Text));
// A `/Btn` splits three ways on its flags.
let radio = FieldFlags::from_bits(1 << 15);
assert_eq!(FieldKind::classify(b"Btn", radio), Some(FieldKind::Radio));
assert_eq!(FieldKind::classify(b"Btn", FieldFlags::default()), Some(FieldKind::Check));
// No field type at all: an interior naming node, not a field.
assert_eq!(FieldKind::classify(b"", FieldFlags::default()), None);
Source

pub fn is_writable(self) -> bool

Whether the field holds a value a caller can write.

False only for FieldKind::Button, which fires an action rather than storing anything, and FieldKind::Signature, whose value is a signature dictionary this crate does not synthesize.

use pdfrum_doc::form::FieldKind;

assert!(FieldKind::Text.is_writable());
assert!(!FieldKind::Button.is_writable());
assert!(!FieldKind::Signature.is_writable());
Source

pub fn is_toggle(self) -> bool

Whether the field is one of the two on/off controls, whose value is a state name rather than free text.

use pdfrum_doc::form::FieldKind;

assert!(FieldKind::Check.is_toggle());
assert!(FieldKind::Radio.is_toggle());
assert!(!FieldKind::Combo.is_toggle());

Trait Implementations§

Source§

impl Clone for FieldKind

Source§

fn clone(&self) -> FieldKind

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 FieldKind

Source§

impl Debug for FieldKind

Source§

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

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

impl Eq for FieldKind

Source§

impl Hash for FieldKind

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 FieldKind

Source§

fn eq(&self, other: &FieldKind) -> 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 FieldKind

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.