Skip to main content

AnnotFlags

Struct AnnotFlags 

Source
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

Source

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

pub const HIDDEN: Self

Bit 2: not displayed and not printed at all.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::HIDDEN.is_hidden());
Source

pub const PRINT: Self

Bit 3: appears in printed output.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::PRINT.prints());
Source

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

pub const NO_ROTATE: Self

Bit 5: the annotation ignores the page’s rotation.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::NO_ROTATE.no_rotate());
Source

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

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

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

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

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

pub const NONE: Self

No bit set.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::NONE.is_empty());
assert!(AnnotFlags::NONE.names().is_empty());
Source

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

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

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

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

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

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

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

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

pub const fn is_hidden(self) -> bool

The annotation is not displayed and not printed at all.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::HIDDEN.is_hidden());
assert!(!AnnotFlags::PRINT.is_hidden());
Source

pub const fn prints(self) -> bool

The annotation appears in printed output.

use pdfrum_doc::AnnotFlags;

assert!(AnnotFlags::PRINT.prints());
assert!(!AnnotFlags::NONE.prints());
Source

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

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

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

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

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

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

Source§

type Output = AnnotFlags

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Self) -> Self

Performs the | operation. Read more
Source§

impl Clone for AnnotFlags

Source§

fn clone(&self) -> AnnotFlags

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 AnnotFlags

Source§

impl Debug for AnnotFlags

Source§

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

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

impl Default for AnnotFlags

Source§

fn default() -> AnnotFlags

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

impl Eq for AnnotFlags

Source§

impl Hash for AnnotFlags

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 AnnotFlags

Source§

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

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.