pdfium_render/pdf/document/page/field/
option.rs

1//! Defines the [PdfFormFieldOption] struct, exposing functionality related to a single selectable
2//! option in a [PdfFormFieldOptions] collection.
3
4use crate::pdf::document::page::field::options::PdfFormFieldOptionIndex;
5
6/// A single selectable option in a list box or check box form field widget.
7pub struct PdfFormFieldOption {
8    index: PdfFormFieldOptionIndex,
9    is_set: bool,
10    label: Option<String>,
11}
12
13impl PdfFormFieldOption {
14    #[inline]
15    pub(crate) fn new(index: PdfFormFieldOptionIndex, is_set: bool, label: Option<String>) -> Self {
16        PdfFormFieldOption {
17            index,
18            is_set,
19            label,
20        }
21    }
22
23    /// Returns the zero-based index of this option in its containing form field.
24    #[inline]
25    pub fn index(&self) -> PdfFormFieldOptionIndex {
26        self.index
27    }
28
29    /// Returns `true` if this option is selected.
30    #[inline]
31    pub fn is_set(&self) -> bool {
32        self.is_set
33    }
34
35    /// Returns the displayed label for this option, if any.
36    #[inline]
37    pub fn label(&self) -> Option<&String> {
38        self.label.as_ref()
39    }
40}