Skip to main content

Update

Struct Update 

Source
pub struct Update<'a> { /* private fields */ }
Expand description

A base document plus the update section being built over it.

Implementations§

Source§

impl<'a> Update<'a>

Source

pub fn new(doc: &'a Document) -> Result<Update<'a>>

Opens doc for an update: refuses an encrypted base or one missing /Root or a startxref to chain the appended section’s /Prev to.

Source

pub fn set(&mut self, r: ObjRef, obj: Object)

Sets an object under its own number, whether new or a replacement of one already in the base.

Source

pub fn remove(&mut self, r: ObjRef)

Marks r free in the appended section’s cross-reference data.

Source

pub fn reserve(&mut self) -> ObjRef

Allocates the next free object number without storing anything under it yet.

Source

pub fn overlay(&self) -> &Overlay

The update section under construction.

Source

pub fn set_metadata(&mut self, meta: Metadata) -> Result<()>

Merges meta into the base document’s /Info dictionary: the ref comes from the overlay’s own info ref when a prior call set one, else the base’s; the dictionary itself always comes from the base document (never from a prior call’s staged fields, so two calls on one Update do not compound; on a base without /Info, a call starts from a fresh dictionary). When the catalog already names an XMP packet, it is rewritten from the merged fields. See set_metadata_with for the merge and rewrite rules.

Source

pub fn append_into(&self, out: impl Write) -> Result<()>

Writes the base bytes, a pad newline when the base needs one, and the appended section into out. The section is built before any byte reaches out, so a refused update (or any other failure) writes nothing at all.

Source

pub fn save(&self, path: impl AsRef<Path>) -> Result<()>

Update::append_into to a new file at path: the file is created only once the update is known to build, so a refused update leaves no file behind at all.

Source

pub fn bytes(&self) -> Result<Vec<u8>>

The base bytes followed by the update section, as one buffer.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Update<'a>

§

impl<'a> !Send for Update<'a>

§

impl<'a> !Sync for Update<'a>

§

impl<'a> !UnwindSafe for Update<'a>

§

impl<'a> Freeze for Update<'a>

§

impl<'a> Unpin for Update<'a>

§

impl<'a> UnsafeUnpin for Update<'a>

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> 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, 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.