Skip to main content

Document

Struct Document 

Source
pub struct Document {
    pub package: Package,
    pub content: Element,
    pub styles_part: Option<Element>,
    pub styles: Styles,
    pub meta: Meta,
}
Expand description

A document read from a package: everything the three formats share.

Fields§

§package: Package

The package itself, which keeps every entry whether or not it was read here, so that writing gives back a document and not a subset of one.

§content: Element

The parsed content.xml.

§styles_part: Option<Element>

The parsed styles.xml, if the package has one.

§styles: Styles

Every style in the document, from both parts.

§meta: Meta

What the document says about itself.

Implementations§

Source§

impl Document

Source

pub fn read( bytes: &[u8], wanted: &'static [&'static str], ) -> Result<Self, Error>

Read a package and check its media type.

§Errors

The bytes are not a package, the package declares a different media type, or content.xml is absent or not well formed.

Source

pub fn body(&self) -> Option<&Element>

The office:body element, which every format has exactly one of.

Source

pub fn body_of(&self, local: &str) -> Option<&Element>

The part of the body this format keeps its content in: office:text, office:spreadsheet or office:presentation.

Source

pub fn version(&self) -> Option<&str>

The version of the format the document declares, as office:version.

Source

pub fn picture(&self, href: &str) -> Option<&[u8]>

The bytes of a picture, by the xlink:href that referred to it.

A href that names an entry of the package gives those bytes. A href that is a URL to somewhere else gives None: reaching it would be a network request, which nothing in this suite makes.

Source

pub fn write(&mut self) -> Result<Vec<u8>, Error>

Write the document back out, with the parsed parts re-serialized over the ones they were read from.

§Errors

The package could not be assembled.

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