pub struct AnnotFlags(/* private fields */);Expand description
An annotation’s /F flag word (ISO 32000-1 table 165).
A hand-rolled newtype rather than a bitflags dependency, for two reasons
the crate would get wrong: unknown bits round-trip
(AnnotFlags::from_bits keeps the whole word), and the dump needs a
fixed name order — AnnotFlags::names is that order, and the tenth
defined bit, LOCKED_CONTENTS, has no printed name at all.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::PRINT | AnnotFlags::NO_ZOOM;
assert!(f.contains(AnnotFlags::PRINT));
assert_eq!(f.names(), ["Print", "NoZoom"]);
assert_eq!(AnnotFlags::from_bits(1 << 20).bits(), 1 << 20);Implementations§
Source§impl AnnotFlags
impl AnnotFlags
Sourcepub const INVISIBLE: Self
pub const INVISIBLE: Self
Bit 1: an annotation whose subtype the viewer does not handle is not drawn at all, rather than falling back to its appearance stream.
Only widgets consult it here — CPDFSDK_BAAnnot::IsVisible adds it,
and Pass A never tests it.
use pdfrum_doc::AnnotFlags;
assert_eq!(AnnotFlags::INVISIBLE.bits(), 1);
assert!(!AnnotFlags::INVISIBLE.is_visible());Sourcepub const HIDDEN: Self
pub const HIDDEN: Self
Bit 2: not displayed and not printed at all.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::HIDDEN.is_hidden());Sourcepub const PRINT: Self
pub const PRINT: Self
Bit 3: appears in printed output.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.prints());Sourcepub const NO_ZOOM: Self
pub const NO_ZOOM: Self
Bit 4: the annotation keeps its size when the page is zoomed.
use pdfrum_doc::AnnotFlags;
assert!(!AnnotFlags::NO_ZOOM.zooms());Sourcepub const NO_ROTATE: Self
pub const NO_ROTATE: Self
Bit 5: the annotation ignores the page’s rotation.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NO_ROTATE.no_rotate());Sourcepub const NO_VIEW: Self
pub const NO_VIEW: Self
Bit 6: suppressed on screen, though it may still print.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NO_VIEW.no_view());Sourcepub const READ_ONLY: Self
pub const READ_ONLY: Self
Bit 7: the annotation does not interact with the user.
use pdfrum_doc::AnnotFlags;
assert_eq!(AnnotFlags::READ_ONLY.names(), ["ReadOnly"]);Sourcepub const LOCKED: Self
pub const LOCKED: Self
Bit 8: the annotation may not be deleted, moved or resized.
use pdfrum_doc::AnnotFlags;
assert_eq!(AnnotFlags::LOCKED.names(), ["Locked"]);Sourcepub const TOGGLE_NO_VIEW: Self
pub const TOGGLE_NO_VIEW: Self
Bit 9: AnnotFlags::NO_VIEW’s sense is inverted for the viewer’s
own idea of “selected”.
use pdfrum_doc::AnnotFlags;
assert_eq!(AnnotFlags::TOGGLE_NO_VIEW.names(), ["ToggleNoView"]);Sourcepub const LOCKED_CONTENTS: Self
pub const LOCKED_CONTENTS: Self
Bit 10: the annotation’s contents may not be changed.
The one defined bit the dump has no printed name for.
use pdfrum_doc::AnnotFlags;
// The one defined bit with no printed name.
assert!(AnnotFlags::LOCKED_CONTENTS.names().is_empty());Sourcepub const NONE: Self
pub const NONE: Self
No bit set.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NONE.is_empty());
assert!(AnnotFlags::NONE.names().is_empty());Sourcepub const fn bits(self) -> i64
pub const fn bits(self) -> i64
The raw /F word, including any bit this type does not name.
use pdfrum_doc::AnnotFlags;
assert_eq!((AnnotFlags::PRINT | AnnotFlags::LOCKED).bits(), 4 | 128);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 reserved bit a damaged file sets is kept, not dropped.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::from_bits((1 << 20) | 4);
assert!(f.prints());
assert_eq!(f.bits(), (1 << 20) | 4);Sourcepub const fn contains(self, other: Self) -> bool
pub const fn contains(self, other: Self) -> bool
Whether every bit of other is set here.
AnnotFlags::NONE is contained in everything, so contains is the
wrong question to ask about “no flags at all” — use
== AnnotFlags::NONE.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::PRINT | AnnotFlags::NO_VIEW;
assert!(f.contains(AnnotFlags::PRINT));
assert!(!f.contains(AnnotFlags::PRINT | AnnotFlags::LOCKED));
// Every flag word contains the empty one.
assert!(f.contains(AnnotFlags::NONE));Sourcepub const fn union(self, other: Self) -> Self
pub const fn union(self, other: Self) -> Self
Both sets of bits.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::PRINT.union(AnnotFlags::LOCKED);
assert_eq!(f.names(), ["Print", "Locked"]);Sourcepub const fn with(self, other: Self) -> Self
pub const fn with(self, other: Self) -> Self
A copy with other’s bits set. An alias for AnnotFlags::union.
use pdfrum_doc::AnnotFlags;
assert_eq!(AnnotFlags::NONE.with(AnnotFlags::LOCKED), AnnotFlags::LOCKED);Sourcepub const fn without(self, other: Self) -> Self
pub const fn without(self, other: Self) -> Self
The bits of self that are not in other.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::PRINT | AnnotFlags::NO_VIEW;
assert!(f.without(AnnotFlags::NO_VIEW).views());Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Whether no bit at all is set.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NONE.is_empty());
assert!(!AnnotFlags::PRINT.is_empty());Sourcepub const fn is_visible(self) -> bool
pub const fn is_visible(self) -> bool
The annotation is drawn even when its subtype has no handler.
The positive reading of the spec’s Invisible bit, and the bit
alone: whether an annotation is actually drawn also depends on
AnnotFlags::is_hidden, AnnotFlags::no_view and the subtype.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.is_visible());
assert!(!AnnotFlags::INVISIBLE.is_visible());The annotation is not displayed and not printed at all.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::HIDDEN.is_hidden());
assert!(!AnnotFlags::PRINT.is_hidden());Sourcepub const fn prints(self) -> bool
pub const fn prints(self) -> bool
The annotation appears in printed output.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.prints());
assert!(!AnnotFlags::NONE.prints());Sourcepub const fn views(self) -> bool
pub const fn views(self) -> bool
The annotation is shown on screen.
The positive reading of the spec’s NoView bit.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.views());
assert!(!AnnotFlags::NO_VIEW.views());Sourcepub const fn no_view(self) -> bool
pub const fn no_view(self) -> bool
The annotation is suppressed on screen.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NO_VIEW.no_view());
assert!(!AnnotFlags::PRINT.no_view());Sourcepub const fn zooms(self) -> bool
pub const fn zooms(self) -> bool
The annotation scales with the page.
The positive reading of the spec’s NoZoom bit.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.zooms());
assert!(!AnnotFlags::NO_ZOOM.zooms());Sourcepub const fn rotates(self) -> bool
pub const fn rotates(self) -> bool
The annotation turns with the page.
The positive reading of the spec’s NoRotate bit.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::PRINT.rotates());
assert!(!AnnotFlags::NO_ROTATE.rotates());Sourcepub const fn no_rotate(self) -> bool
pub const fn no_rotate(self) -> bool
The annotation ignores the page’s rotation.
use pdfrum_doc::AnnotFlags;
assert!(AnnotFlags::NO_ROTATE.no_rotate());
assert!(!AnnotFlags::PRINT.no_rotate());Sourcepub fn names(self) -> Vec<&'static str>
pub fn names(self) -> Vec<&'static str>
The set flags’ names, in bit order.
The order is the dump’s — --annot prints exactly this sequence,
and AnnotFlags::LOCKED_CONTENTS never appears because it has no
printed name.
use pdfrum_doc::AnnotFlags;
let f = AnnotFlags::from_bits(4 | 8 | 16);
assert_eq!(f.names(), ["Print", "NoZoom", "NoRotate"]);Trait Implementations§
Source§impl BitOr for AnnotFlags
impl BitOr for AnnotFlags
Source§impl Clone for AnnotFlags
impl Clone for AnnotFlags
Source§fn clone(&self) -> AnnotFlags
fn clone(&self) -> AnnotFlags
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more